Skip to content

feat(s3): introduce a fromCfnBucket() method#20081

Merged
mergify[bot] merged 9 commits intoaws:mainfrom
skinny85:from-cfn-bucket
Aug 11, 2022
Merged

feat(s3): introduce a fromCfnBucket() method#20081
mergify[bot] merged 9 commits intoaws:mainfrom
skinny85:from-cfn-bucket

Conversation

@skinny85
Copy link
Copy Markdown
Contributor

This PR adds a new static method to the Bucket class in the S3 module,
fromCfnBucket(), that allows creating an L2 IBucket from a CfnBucket instance.
This is useful when migrating from CloudFormation to CDK.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@skinny85 skinny85 requested a review from rix0rrr April 25, 2022 23:17
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Apr 25, 2022

@github-actions github-actions bot added the p2 label Apr 25, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team April 25, 2022 23:17
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 25, 2022
@skinny85
Copy link
Copy Markdown
Contributor Author

I think the most interesting part of this PR is how to handle the policy property of IBucket in the fromCfnBucket() method.

Since it's the Policy that has the reference to the Bucket, and not the other way round, I've decided to not fill this property in fromCfnBucket() at all. Instead, I've introduced a similar method in BucketPolicy, fromCfnBucketPolicy(), and I find the Bucket that the Policy is referencing, and I fill the new bucket property that I've added to BucketPolicy. Of course, fromCfnBucketPolicy() calls fromCfnBucket() in its implementation.

I'm curious on the opinion of this solution. I could be convinced that we need to pass some sort of optional "template" property as the second argument to fromCfnBucket() which allows the code to search the template for all Bucket Policies that reference the given Bucket, and our CfnInclude class would implement this "template" interface.

Let me know what you think @rix0rrr!

@skinny85 skinny85 added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Apr 25, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the base branch from v1-main to main July 13, 2022 00:07
@otaviomacedo
Copy link
Copy Markdown
Contributor

To others, who might come across this PR, I am resolving the conflicts and making sure the tests pass.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 11, 2022

Thank you for contributing! Your pull request will be updated from main 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: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 92cfc18
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 11, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 0ec31da into aws:main Aug 11, 2022
@skinny85 skinny85 deleted the from-cfn-bucket branch August 12, 2022 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants