io.github.cdklabs.cdk.ecs.codedeploy.ApiCanary Maven / Gradle / Ivy
Show all versions of cdk-ecs-codedeploy Show documentation
package io.github.cdklabs.cdk.ecs.codedeploy;
/**
* (experimental) A CloudWatch Synthetic Canary for monitoring APIs.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.103.1 (build bef2dea)", date = "2024-10-04T18:24:15.078Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Jsii(module = io.github.cdklabs.cdk.ecs.codedeploy.$Module.class, fqn = "@cdklabs/cdk-ecs-codedeploy.ApiCanary")
public class ApiCanary extends software.amazon.awscdk.services.synthetics.Canary {
protected ApiCanary(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected ApiCanary(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param scope This parameter is required.
* @param id This parameter is required.
* @param props This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public ApiCanary(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull io.github.cdklabs.cdk.ecs.codedeploy.ApiCanaryProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") });
}
/**
* (experimental) Add a new test step to this canary.
*
* @param step
- ApiTestStep to add.
This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void addTestStep(final @org.jetbrains.annotations.NotNull io.github.cdklabs.cdk.ecs.codedeploy.ApiTestStep step) {
software.amazon.jsii.Kernel.call(this, "addTestStep", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(step, "step is required") });
}
/**
* (experimental) A CloudWatch Alarm that triggers when the success rate falls below 100% over the past 2 periods.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.cloudwatch.Alarm getSuccessAlarm() {
return software.amazon.jsii.Kernel.get(this, "successAlarm", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.cloudwatch.Alarm.class));
}
/**
* (experimental) A CloudWatch Alarm that triggers when the success rate falls below 100% over the past 2 periods.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void setSuccessAlarm(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.cloudwatch.Alarm value) {
software.amazon.jsii.Kernel.set(this, "successAlarm", java.util.Objects.requireNonNull(value, "successAlarm is required"));
}
/**
* (experimental) A CloudWatch Alarm that triggers when the duration of the tests exceeds the given threshold over the past 2 periods.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.cloudwatch.Alarm getDurationAlarm() {
return software.amazon.jsii.Kernel.get(this, "durationAlarm", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.cloudwatch.Alarm.class));
}
/**
* (experimental) A CloudWatch Alarm that triggers when the duration of the tests exceeds the given threshold over the past 2 periods.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void setDurationAlarm(final @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.cloudwatch.Alarm value) {
software.amazon.jsii.Kernel.set(this, "durationAlarm", value);
}
/**
* (experimental) A fluent builder for {@link io.github.cdklabs.cdk.ecs.codedeploy.ApiCanary}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param scope This parameter is required.
* @param id This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static Builder create(final software.constructs.Construct scope, final java.lang.String id) {
return new Builder(scope, id);
}
private final software.constructs.Construct scope;
private final java.lang.String id;
private final io.github.cdklabs.cdk.ecs.codedeploy.ApiCanaryProps.Builder props;
private Builder(final software.constructs.Construct scope, final java.lang.String id) {
this.scope = scope;
this.id = id;
this.props = new io.github.cdklabs.cdk.ecs.codedeploy.ApiCanaryProps.Builder();
}
/**
* (experimental) The base URL to use for tests.
*
* @return {@code this}
* @param baseUrl The base URL to use for tests. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder baseUrl(final java.lang.String baseUrl) {
this.props.baseUrl(baseUrl);
return this;
}
/**
* (experimental) The s3 location that stores the data of the canary runs.
*
* Default: - A new s3 bucket will be created without a prefix.
*
* @return {@code this}
* @param artifactsBucketLocation The s3 location that stores the data of the canary runs. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder artifactsBucketLocation(final software.amazon.awscdk.services.synthetics.ArtifactsBucketLocation artifactsBucketLocation) {
this.props.artifactsBucketLocation(artifactsBucketLocation);
return this;
}
/**
* (experimental) The name of the canary.
*
* Be sure to give it a descriptive name that distinguishes it from
* other canaries in your account.
*
* Do not include secrets or proprietary information in your canary name. The canary name
* makes up part of the canary ARN, which is included in outbound calls over the internet.
*
* Default: - A unique name will be generated from the construct ID
*
* @return {@code this}
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html
* @param canaryName The name of the canary. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder canaryName(final java.lang.String canaryName) {
this.props.canaryName(canaryName);
return this;
}
/**
* (experimental) The threshold for triggering an alarm on the test duration.
*
* Default: - no alarm is created for duration
*
* @return {@code this}
* @param durationAlarmThreshold The threshold for triggering an alarm on the test duration. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder durationAlarmThreshold(final software.amazon.awscdk.Duration durationAlarmThreshold) {
this.props.durationAlarmThreshold(durationAlarmThreshold);
return this;
}
/**
* (experimental) How many days should failed runs be retained.
*
* Default: Duration.days(31)
*
* @return {@code this}
* @param failureRetentionPeriod How many days should failed runs be retained. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder failureRetentionPeriod(final software.amazon.awscdk.Duration failureRetentionPeriod) {
this.props.failureRetentionPeriod(failureRetentionPeriod);
return this;
}
/**
* (experimental) Canary execution role.
*
* This is the role that will be assumed by the canary upon execution.
* It controls the permissions that the canary will have. The role must
* be assumable by the AWS Lambda service principal.
*
* If not supplied, a role will be created with all the required permissions.
* If you provide a Role, you must add the required permissions.
*
* Default: - A unique role will be generated for this canary.
* You can add permissions to roles by calling 'addToRolePolicy'.
*
* @return {@code this}
* @see required permissions: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-executionrolearn
* @param role Canary execution role. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder role(final software.amazon.awscdk.services.iam.IRole role) {
this.props.role(role);
return this;
}
/**
* (experimental) Specify the schedule for how often the canary runs.
*
* For example, if you set schedule
to rate(10 minutes)
, then the canary will run every 10 minutes.
* You can set the schedule with Schedule.rate(Duration)
(recommended) or you can specify an expression using Schedule.expression()
.
*
* Default: 'rate(5 minutes)'
*
* @return {@code this}
* @param schedule Specify the schedule for how often the canary runs. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder schedule(final software.amazon.awscdk.services.synthetics.Schedule schedule) {
this.props.schedule(schedule);
return this;
}
/**
* (experimental) The list of security groups to associate with the canary's network interfaces.
*
* You must provide vpc
when using this prop.
*
* Default: - If the canary is placed within a VPC and a security group is
* not specified a dedicated security group will be created for this canary.
*
* @return {@code this}
* @param securityGroups The list of security groups to associate with the canary's network interfaces. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder securityGroups(final java.util.List extends software.amazon.awscdk.services.ec2.ISecurityGroup> securityGroups) {
this.props.securityGroups(securityGroups);
return this;
}
/**
* (experimental) Whether or not the canary should start after creation.
*
* Default: true
*
* @return {@code this}
* @param startAfterCreation Whether or not the canary should start after creation. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder startAfterCreation(final java.lang.Boolean startAfterCreation) {
this.props.startAfterCreation(startAfterCreation);
return this;
}
/**
* (experimental) The steps to perform in the synthetic test.
*
* @return {@code this}
* @param steps The steps to perform in the synthetic test. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder steps(final java.util.List extends io.github.cdklabs.cdk.ecs.codedeploy.ApiTestStep> steps) {
this.props.steps(steps);
return this;
}
/**
* (experimental) How many days should successful runs be retained.
*
* Default: Duration.days(31)
*
* @return {@code this}
* @param successRetentionPeriod How many days should successful runs be retained. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder successRetentionPeriod(final software.amazon.awscdk.Duration successRetentionPeriod) {
this.props.successRetentionPeriod(successRetentionPeriod);
return this;
}
/**
* (experimental) The number of threads to run concurrently for the synthetic test.
*
* Default: - 20
*
* @return {@code this}
* @param threadCount The number of threads to run concurrently for the synthetic test. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder threadCount(final java.lang.Number threadCount) {
this.props.threadCount(threadCount);
return this;
}
/**
* (experimental) How long the canary will be in a 'RUNNING' state.
*
* For example, if you set timeToLive
to be 1 hour and schedule
to be rate(10 minutes)
,
* your canary will run at 10 minute intervals for an hour, for a total of 6 times.
*
* Default: - no limit
*
* @return {@code this}
* @param timeToLive How long the canary will be in a 'RUNNING' state. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder timeToLive(final software.amazon.awscdk.Duration timeToLive) {
this.props.timeToLive(timeToLive);
return this;
}
/**
* (experimental) The VPC where this canary is run.
*
* Specify this if the canary needs to access resources in a VPC.
*
* Default: - Not in VPC
*
* @return {@code this}
* @param vpc The VPC where this canary is run. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder vpc(final software.amazon.awscdk.services.ec2.IVpc vpc) {
this.props.vpc(vpc);
return this;
}
/**
* (experimental) Where to place the network interfaces within the VPC.
*
* You must provide vpc
when using this prop.
*
* Default: - the Vpc default strategy if not specified
*
* @return {@code this}
* @param vpcSubnets Where to place the network interfaces within the VPC. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder vpcSubnets(final software.amazon.awscdk.services.ec2.SubnetSelection vpcSubnets) {
this.props.vpcSubnets(vpcSubnets);
return this;
}
/**
* @return a newly built instance of {@link io.github.cdklabs.cdk.ecs.codedeploy.ApiCanary}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public io.github.cdklabs.cdk.ecs.codedeploy.ApiCanary build() {
return new io.github.cdklabs.cdk.ecs.codedeploy.ApiCanary(
this.scope,
this.id,
this.props.build()
);
}
}
}