Skip to content

feat(s3-deployment): add deployedBucket attribute for sequencing#15384

Merged
mergify[bot] merged 14 commits intomasterfrom
huijbers/deployed-bucket
Feb 18, 2022
Merged

feat(s3-deployment): add deployedBucket attribute for sequencing#15384
mergify[bot] merged 14 commits intomasterfrom
huijbers/deployed-bucket

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented Jul 1, 2021

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.

TODO:

- Tests
- Docstrings
- README
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jul 1, 2021

@rix0rrr rix0rrr requested a review from skinny85 July 1, 2021 15:00
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 1, 2021
@BryanPan342
Copy link
Copy Markdown
Contributor

@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.

@rix0rrr
Copy link
Copy Markdown
Contributor Author

rix0rrr commented Jul 2, 2021

@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.

@rix0rrr
Copy link
Copy Markdown
Contributor Author

rix0rrr commented Jul 5, 2021

I can't approve this since I opened the PR. So we need @skinny85 in the game 🙂

Copy link
Copy Markdown
Contributor

@skinny85 skinny85 left a 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.

DistributionId: props.distribution?.distributionId,
DistributionPaths: props.distributionPaths,
// Passing through the ARN sequences dependencees on the deployment
PassThroughBucketArn: props.destinationBucket.bucketArn,
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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   │
│            │                 │                    │                │                    │
└────────────┘                 └────────────────────┘                └────────────────────┘

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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 🙂.

Copy link
Copy Markdown
Contributor Author

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')));
Copy link
Copy Markdown
Contributor

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.

@skinny85 skinny85 added the pr/do-not-merge This PR should not be merged at this time. label Jul 6, 2021
@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Aug 13, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 18, 2022

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-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 1ad1719
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit edac101 into master Feb 18, 2022
@mergify mergify bot deleted the huijbers/deployed-bucket branch February 18, 2022 12:04
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 18, 2022

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).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@aws-cdk/aws-s3-deployment contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants