-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(s3-deployment): add deployedBucket
attribute for sequencing
#15384
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
Conversation
This allows referencing the bucket in a way that ensures the deployment has happened before dependent resources are created. TODO: - Tests - Docstrings - README
@rix0rrr would we consider this a breaking change? bc the asset id's change as a result of this! So some people who run tests might have their systems break. |
No. Snapshot testing w/ asset hashes is something people shouldn't be doing. |
I can't approve this since I opened the PR. So we need @skinny85 in the game 🙂 |
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.
LGTM. Two minor comments.
@@ -235,9 +250,12 @@ export class BucketDeployment extends CoreConstruct { | |||
SystemMetadata: mapSystemMetadata(props), | |||
DistributionId: props.distribution?.distributionId, | |||
DistributionPaths: props.distributionPaths, | |||
// Passing through the ARN sequences dependencees on the deployment | |||
PassThroughBucketArn: props.destinationBucket.bucketArn, |
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.
Can't we just use the existing DestinationBucketName
to do this sequencing? Won't it have the same effect, without changing the customer's template?
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.
I'm not sure I follow. If it doesn't change the template, it won't enforce sequencing, right?
Right now, the dependencies look like this, which lead to a race condition:
┌────────────────────┐
{ Ref: Bucket } │ │
┌────────────│ Deployment │
│ │ │
┌────────────┐ │ └────────────────────┘
│ │ │
│ Bucket │◀───────────┤
│ │ │
└────────────┘ │ ┌────────────────────┐
│ │ │
└────────────│ BucketConsumer │
{ Ref: Bucket } │ │
└────────────────────┘
We want them to look like this:
{ GetAtt: [..., 'BucketArn'] }
┌────────────┐ ┌────────────────────┐ ┌────────────────────┐
│ │ { Ref: Bucket } │ │ │ │
│ Bucket │◀────────────────│ Deployment │◀───────────────│ BucketConsumer │
│ │ │ │ │ │
└────────────┘ └────────────────────┘ └────────────────────┘
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.
I meant template changes related to the new PassThroughBucketArn
property that you added, regardless of whether your customers use the new deployedBucket
property or not.
If you used the existing DestinationBucketName
property for this purpose, I believe existing customers would not have their template affected.
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.
Oh I see. Is that good enough though? What if the bucket is in another account?
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.
If it's in another account, sequencing within the template with Fn::GetAtt
is irrelevant anyway 🙂.
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.
That is true, using the bucket still shouldn't fail.
}, | ||
}); | ||
|
||
this.deployedBucket = s3.Bucket.fromBucketArn(this, 'DestinationBucket', Token.asString(deployment.getAtt('DestinationBucketArn'))); |
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.
Pretty sure we're missing a unit test for actually using this property in another construct.
924c117
to
ebfd5f2
Compare
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…ws#15384) This allows referencing the bucket in a way that ensures the deployment has happened before dependent resources are created. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This allows referencing the bucket in a way that ensures the
deployment has happened before dependent resources are created.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license