-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-opensearchservice: Domain creates new ResourcePolicy if logging enabled #23637
Comments
related to #22307 Yes we are aware of the resource policy number limit and we definitely should have a workaround for that. |
This is an issue for us too. We run into a hard AWS limit of ten Opensearch domains per region when logging is enabled, preventing us from spinning up as many demos as we need for development.
Looking at the CDK code a new CustomResource LogGroupResourcePolicy is created automatically for every domain (when any logging is enabled) without the ability to prevent its creation or use a broader policy: aws-cdk/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts Lines 1492 to 1507 in c224fc3
Would it be possible to use a previously created broader resource policy per the suggestion in the docs, or somehow stop the CDK from trying to create a new one if logs are enabled? |
what's the workaround here? |
@XiaowenMaoA const domain = new opensearch.Domain(this, 'Domain', domainProps);
const domainResource = domain.node.defaultChild as opensearch.CfnDomain;
domainResource.addOverride('DependsOn', undefined);
domain.node.children
.filter(child => child instanceof AwsCustomResource)
.forEach(value => domain.node.tryRemoveChild(value.node.id)); |
…ogging is enabled (#28707) This PR adds an option to suppress the creation of logs resource policy when logging is enabled. ### Description Currently, a CloudWatch Logs resource policy is created by default when the Domain logging is enabled. However, since only ten resource policies can be created per region, deploying multiple Domains may cause errors. The `tryRemoveChild` method can be used as a workaround to delete custom resources, but a better user experience is desirable. ```ts const domain = new opensearch.Domain(this, 'Domain', domainProps); const domainResource = domain.node.defaultChild as opensearch.CfnDomain; domainResource.addOverride('DependsOn', undefined); // remove dependency on the custom resource domain.node.children .filter(child => child instanceof AwsCustomResource) .forEach(value => domain.node.tryRemoveChild(value.node.id)); ``` So, I add an option to suppress the creation of resource policies. This option allows users to reuse a broader resource policy and successfully deploy several domains. https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createdomain-configure-slow-logs.html#:~:text=Resource%22%3A%20%22cw_log_group_arn%3A*%22%7D%5D%7D%27-,Important,-CloudWatch%20Logs%20supports Closes #23637 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…ogging is enabled (aws#28707) This PR adds an option to suppress the creation of logs resource policy when logging is enabled. ### Description Currently, a CloudWatch Logs resource policy is created by default when the Domain logging is enabled. However, since only ten resource policies can be created per region, deploying multiple Domains may cause errors. The `tryRemoveChild` method can be used as a workaround to delete custom resources, but a better user experience is desirable. ```ts const domain = new opensearch.Domain(this, 'Domain', domainProps); const domainResource = domain.node.defaultChild as opensearch.CfnDomain; domainResource.addOverride('DependsOn', undefined); // remove dependency on the custom resource domain.node.children .filter(child => child instanceof AwsCustomResource) .forEach(value => domain.node.tryRemoveChild(value.node.id)); ``` So, I add an option to suppress the creation of resource policies. This option allows users to reuse a broader resource policy and successfully deploy several domains. https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createdomain-configure-slow-logs.html#:~:text=Resource%22%3A%20%22cw_log_group_arn%3A*%22%7D%5D%7D%27-,Important,-CloudWatch%20Logs%20supports Closes aws#23637 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ogging is enabled (#28707) This PR adds an option to suppress the creation of logs resource policy when logging is enabled. ### Description Currently, a CloudWatch Logs resource policy is created by default when the Domain logging is enabled. However, since only ten resource policies can be created per region, deploying multiple Domains may cause errors. The `tryRemoveChild` method can be used as a workaround to delete custom resources, but a better user experience is desirable. ```ts const domain = new opensearch.Domain(this, 'Domain', domainProps); const domainResource = domain.node.defaultChild as opensearch.CfnDomain; domainResource.addOverride('DependsOn', undefined); // remove dependency on the custom resource domain.node.children .filter(child => child instanceof AwsCustomResource) .forEach(value => domain.node.tryRemoveChild(value.node.id)); ``` So, I add an option to suppress the creation of resource policies. This option allows users to reuse a broader resource policy and successfully deploy several domains. https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createdomain-configure-slow-logs.html#:~:text=Resource%22%3A%20%22cw_log_group_arn%3A*%22%7D%5D%7D%27-,Important,-CloudWatch%20Logs%20supports Closes #23637 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
Creating a new OpenSearch domain creates a new ResourcePolicy every time if any of: slowSearchLogEnabled, slowIndexLogEnabled, appLogEnabled, auditLogEnabled is true.
According to the CloudWatch limits:
We're hitting this quota easily since every domain we create creates a new ResourcePolicy
Expected Behavior
Not sure what what would be a good expected behavior.
May be: Reuse a previously created ResourcePolicy and add the new log policy statement.
Current Behavior
A new resource policy is created with every new domain that is created with logging enabled.
Reproduction Steps
Instantiate a new Domain and set any of the log types as true:
Possible Solution
Reuse a previously created ResourcePolicy and add the new log policy statement.
Additional Information/Context
No response
CDK CLI Version
1.187.0
Framework Version
1.187.0
Node.js Version
16.19.0
OS
Linux
Language
Typescript
Language Version
4.4.3
Other information
No response
The text was updated successfully, but these errors were encountered: