-
Notifications
You must be signed in to change notification settings - Fork 17
/
CanaryProps.go
133 lines (130 loc) · 6.03 KB
/
CanaryProps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package awssynthetics
import (
"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/aws-cdk-go/awscdk/v2/awsec2"
"github.com/aws/aws-cdk-go/awscdk/v2/awsiam"
"github.com/aws/aws-cdk-go/awscdk/v2/awss3"
)
// Properties for a canary.
//
// Example:
// canary := synthetics.NewCanary(this, jsii.String("MyCanary"), &CanaryProps{
// Schedule: synthetics.Schedule_Rate(awscdk.Duration_Minutes(jsii.Number(5))),
// Test: synthetics.Test_Custom(&CustomTestOptions{
// Code: synthetics.Code_FromAsset(path.join(__dirname, jsii.String("canary"))),
// Handler: jsii.String("index.handler"),
// }),
// Runtime: synthetics.Runtime_SYNTHETICS_NODEJS_PUPPETEER_6_0(),
// EnvironmentVariables: map[string]*string{
// "stage": jsii.String("prod"),
// },
// })
//
type CanaryProps struct {
// Specify the runtime version to use for the canary.
// See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Library.html
//
Runtime Runtime `field:"required" json:"runtime" yaml:"runtime"`
// The type of test that you want your canary to run.
//
// Use `Test.custom()` to specify the test to run.
Test Test `field:"required" json:"test" yaml:"test"`
// Lifecycle rules for the generated canary artifact bucket.
//
// Has no effect
// if a bucket is passed to `artifactsBucketLocation`. If you pass a bucket
// to `artifactsBucketLocation`, you can add lifecycle rules to the bucket
// itself.
// Default: - no rules applied to the generated bucket.
//
ArtifactsBucketLifecycleRules *[]*awss3.LifecycleRule `field:"optional" json:"artifactsBucketLifecycleRules" yaml:"artifactsBucketLifecycleRules"`
// The s3 location that stores the data of the canary runs.
// Default: - A new s3 bucket will be created without a prefix.
//
ArtifactsBucketLocation *ArtifactsBucketLocation `field:"optional" json:"artifactsBucketLocation" yaml:"artifactsBucketLocation"`
// 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.
// See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html
//
// Default: - A unique name will be generated from the construct ID.
//
CanaryName *string `field:"optional" json:"canaryName" yaml:"canaryName"`
// Specify the underlying resources to be cleaned up when the canary is deleted.
//
// Using `Cleanup.LAMBDA` will create a Custom Resource to achieve this.
// Default: Cleanup.NOTHING
//
Cleanup Cleanup `field:"optional" json:"cleanup" yaml:"cleanup"`
// Key-value pairs that the Synthetics caches and makes available for your canary scripts.
//
// Use environment variables
// to apply configuration changes, such as test and production environment configurations, without changing your
// Canary script source code.
// Default: - No environment variables.
//
EnvironmentVariables *map[string]*string `field:"optional" json:"environmentVariables" yaml:"environmentVariables"`
// How many days should failed runs be retained.
// Default: Duration.days(31)
//
FailureRetentionPeriod awscdk.Duration `field:"optional" json:"failureRetentionPeriod" yaml:"failureRetentionPeriod"`
// 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.
// See: required permissions: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-executionrolearn
//
// Default: - A unique role will be generated for this canary.
// You can add permissions to roles by calling 'addToRolePolicy'.
//
Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
// 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)'.
//
Schedule Schedule `field:"optional" json:"schedule" yaml:"schedule"`
// 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.
//
SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"`
// Whether or not the canary should start after creation.
// Default: true.
//
StartAfterCreation *bool `field:"optional" json:"startAfterCreation" yaml:"startAfterCreation"`
// How many days should successful runs be retained.
// Default: Duration.days(31)
//
SuccessRetentionPeriod awscdk.Duration `field:"optional" json:"successRetentionPeriod" yaml:"successRetentionPeriod"`
// 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.
//
TimeToLive awscdk.Duration `field:"optional" json:"timeToLive" yaml:"timeToLive"`
// The VPC where this canary is run.
//
// Specify this if the canary needs to access resources in a VPC.
// Default: - Not in VPC.
//
Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
// 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.
//
VpcSubnets *awsec2.SubnetSelection `field:"optional" json:"vpcSubnets" yaml:"vpcSubnets"`
}