Skip to content
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

chore(cloudfront-origins): grant key permissions to distribution #31188

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

gracelu0
Copy link
Contributor

Changes:

  • grant key permissions to distribution and output info message about circular dependency
  • make distributionId optional
  • rename some variables for clarity

@github-actions github-actions bot added the p2 label Aug 22, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team August 22, 2024 20:25
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 22, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@gracelu0 gracelu0 changed the title fix(cloudfront-origins): grant key permissions to distribution chore(cloudfront-origins): grant key permissions to distribution Aug 22, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 22, 2024 20:33

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

scope,
resolver: new DefaultTokenResolver(new StringConcat()),
}));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have links to examples of this trick when the code is doing JSON.stringify(Tokenization.resolve ... ? Trying to understand what it does. Does it resolve to the logical ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example of usage in iam module:

export function generatePolicyName(scope: IConstruct, logicalId: string): string {
// as logicalId is itself a Token, resolve it first
const resolvedLogicalId = Tokenization.resolve(logicalId, {
scope,
resolver: new DefaultTokenResolver(new StringConcat()),
});
return lastNCharacters(resolvedLogicalId, MAX_POLICY_NAME_LEN);
}

Output from when I tested it locally is like this:

[Info at /MigrationOacStack/MyDistribution/Origin2] Granting OAC permissions to access KMS key for S3 bucket origin {"Ref":"MyBucketF68F3FF0"} may cause a circular dependency error when this stack deploys.
The key policy references the distribution's id, the distribution references the bucket, and the bucket references the key.
See the 'Using OAC for a SSE-KMS encrypted S3 origin' section in the module README for more details.

So yes it resolves to the logical ID. I thought it would be helpful to include the specific resource involved in the info message, but there might be a cleaner way to do this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thank you. Looks good to me.

@gracelu0 gracelu0 merged commit 29382ed into aws:gracelu0/s3-oac-l2 Aug 22, 2024
25 of 27 checks passed
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants