-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(synthetics): lifecycle rules for auto-generated artifact buckets #22863
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -220,3 +220,53 @@ new cloudwatch.Alarm(this, 'CanaryAlarm', { | |||||||||
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, | ||||||||||
}); | ||||||||||
``` | ||||||||||
|
||||||||||
### Artifacts | ||||||||||
|
||||||||||
You can pass an S3 bucket to store artifacts from canary runs. If you do not, one will be auto-generated when the canary is created. You may add [lifecycle rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) to the auto-generated bucket. | ||||||||||
|
||||||||||
Artifact bucket examples: | ||||||||||
|
||||||||||
```typescript | ||||||||||
// Auto-generated bucket with lifecycle rules. | ||||||||||
Comment on lines
+230
to
+231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
const canary = new synthetics.Canary(this, 'MyCanary', { | ||||||||||
schedule: synthetics.Schedule.rate(Duration.minutes(5)), | ||||||||||
test: synthetics.Test.custom({ | ||||||||||
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), | ||||||||||
handler: 'index.handler', | ||||||||||
}), | ||||||||||
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, | ||||||||||
environmentVariables: { | ||||||||||
stage: 'prod', | ||||||||||
}, | ||||||||||
artifactsBucketLifecycleRules: [ | ||||||||||
{ | ||||||||||
expiration: Duration.days(30), | ||||||||||
}, | ||||||||||
] | ||||||||||
}); | ||||||||||
|
||||||||||
// Custom bucket as artifact bucket. | ||||||||||
Comment on lines
+248
to
+249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. github ui doesn't like when my suggestions involve we should split up the example into two here and change the comment to the one below: // configure lifecycle rules on a custom artifact bucket. |
||||||||||
import * as s3 from '@aws-cdk/aws-s3'; | ||||||||||
|
||||||||||
const bucket = new s3.Bucket(this, 'MyArtifactsBucket', { | ||||||||||
encryption: s3.BucketEncryption.KMS_MANAGED, | ||||||||||
enforceSSL: true, | ||||||||||
}); | ||||||||||
|
||||||||||
const canary = new synthetics.Canary(this, 'MyCanary', { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the build is failing because we are creating two |
||||||||||
schedule: synthetics.Schedule.rate(Duration.minutes(5)), | ||||||||||
test: synthetics.Test.custom({ | ||||||||||
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), | ||||||||||
handler: 'index.handler', | ||||||||||
}), | ||||||||||
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, | ||||||||||
environmentVariables: { | ||||||||||
stage: 'prod', | ||||||||||
}, | ||||||||||
artifactsBucketLocation: { | ||||||||||
bucket: bucket, | ||||||||||
} | ||||||||||
}); | ||||||||||
``` | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets delete this line and move it in to the ts example