-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(opensearchservice): create AWS::Logs::ResourcePolicy
instead of Custom::CloudwatchLogResourcePolicy
#34558
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
base: main
Are you sure you want to change the base?
feat(opensearchservice): create AWS::Logs::ResourcePolicy
instead of Custom::CloudwatchLogResourcePolicy
#34558
Conversation
…ustom::CloudwatchLogResourcePolicy
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.
(This review is outdated)
Exemption Request integration test is updated |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
// Use a custom resource to set the log group resource policy since it is not supported by CDK and cfn. | ||
// https://github.com/aws/aws-cdk/issues/5343 | ||
logGroupResourcePolicy = new LogGroupResourcePolicy(this, `ESLogGroupPolicy${this.node.addr}`, { | ||
logGroupResourcePolicy = new logs.ResourcePolicy(this, `ESLogGroupPolicy${this.node.addr}`, { |
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.
Thanks for the contribution. This change is considered a breaking change because:
- There is a possible conflict as CFN tries to create the resource policy before deleting the custom resource, resulting in a resource policy with the same name already exists error.
- Deleting the custom resource first will cause a temporary period where permissions on the logs are lost, as on the delete lifecycle event of the custom resource we remove the policy. Ref:
aws-cdk/packages/aws-cdk-lib/aws-opensearchservice/lib/log-group-resource-policy.ts
Lines 39 to 46 in 54e8222
onDelete: { service: 'CloudWatchLogs', action: 'deleteResourcePolicy', parameters: { policyName: props.policyName, }, ignoreErrorCodesMatching: 'ResourceNotFoundException', },
Therefore we should add a feature flag for this feature with recommended migration steps, and we can default it to enabled for new CDK projects, but we can't automatically enable this for existing cdk projects.
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.
Thanks for reviewing. I added a feature flag.
|
||
////////////////////////////////////////////////////////////////////// | ||
[OPENSEARCHSERVICE_LOG_GROUP_RESOURCE_POLICY_WITHOUT_CUSTOM_RESOURCE]: { | ||
type: FlagType.BugFix, |
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.
this is a feature, not a bug fix.
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.
Please also rename the PR to indicate a feature, as this directly in the change log. Technically we are not fixing a bug in the previous implementation, we are improving it by using the L1 resource.
@@ -1660,6 +1661,19 @@ export const FLAGS: Record<string, FlagInfo> = { | |||
recommendedValue: true, | |||
compatibilityWithOldBehaviorMd: 'Disable the feature flag to let lambda service create logGroup or specify logGroup or logRetention', | |||
}, | |||
|
|||
////////////////////////////////////////////////////////////////////// | |||
[OPENSEARCHSERVICE_LOG_GROUP_RESOURCE_POLICY_WITHOUT_CUSTOM_RESOURCE]: { |
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.
[OPENSEARCHSERVICE_LOG_GROUP_RESOURCE_POLICY_WITHOUT_CUSTOM_RESOURCE]: { | |
[OPENSEARCHSERVICE_CREATE_CLOUDFORMATION_RESOURCE_POLICY]: { |
////////////////////////////////////////////////////////////////////// | ||
[OPENSEARCHSERVICE_LOG_GROUP_RESOURCE_POLICY_WITHOUT_CUSTOM_RESOURCE]: { | ||
type: FlagType.BugFix, | ||
summary: 'When enabled, create log group resource policy without creating a custom resource.', |
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.
summary: 'When enabled, adds a log group resource policy using AWS::Logs::ResourcePolicy, without relying on a custom resource.,
AWS::Logs::ResourcePolicy
instead of Custom::CloudwatchLogResourcePolicy
AWS::Logs::ResourcePolicy
instead of Custom::CloudwatchLogResourcePolicy
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue
Related #5343
Reason for this change
We don't need to create a custom resource to set the log group resource policy since it is supported by CDK and cfn.
aws-cdk/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts
Lines 1880 to 1886 in 54e8222
Description of changes
new logs.ResourcePolicy
instead ofnew LogGroupResourcePolicy
when feature flag is setDescribe any new or updated permissions being added
None
Description of how you validated changes
Pass unit/integ tests
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license