-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
…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*
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"Resources": { | ||
"AppLogsGroupC90FBC0A": { | ||
"Type": "AWS::Logs::LogGroup", | ||
"Properties": { | ||
"RetentionInDays": 731 | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"ResourcePolicyD790E185": { | ||
"Type": "AWS::Logs::ResourcePolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"{\"Statement\":[{\"Action\":[\"logs:CreateLogStream\",\"logs:PutLogEvents\"],\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"es.amazonaws.com\"},\"Resource\":\"", | ||
{ | ||
"Fn::GetAtt": [ | ||
"AppLogsGroupC90FBC0A", | ||
"Arn" | ||
] | ||
}, | ||
"\"}],\"Version\":\"2012-10-17\"}" | ||
] | ||
] | ||
}, | ||
"PolicyName": "cdkinteglogsresourcepolicyResourcePolicyB41E8C17" | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"ExportsOutputFnGetAttAppLogsGroupC90FBC0AArn7BBE8767": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"AppLogsGroupC90FBC0A", | ||
"Arn" | ||
] | ||
}, | ||
"Export": { | ||
"Name": "cdkinteg-logs-resource-policy:ExportsOutputFnGetAttAppLogsGroupC90FBC0AArn7BBE8767" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"Resources": { | ||
"Domain66AC69E0": { | ||
"Type": "AWS::OpenSearchService::Domain", | ||
"Properties": { | ||
"ClusterConfig": { | ||
"DedicatedMasterEnabled": false, | ||
"InstanceCount": 1, | ||
"InstanceType": "r5.large.search", | ||
"MultiAZWithStandbyEnabled": false, | ||
"ZoneAwarenessEnabled": false | ||
}, | ||
"DomainEndpointOptions": { | ||
"EnforceHTTPS": false, | ||
"TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" | ||
}, | ||
"EBSOptions": { | ||
"EBSEnabled": true, | ||
"VolumeSize": 10, | ||
"VolumeType": "gp2" | ||
}, | ||
"EncryptionAtRestOptions": { | ||
"Enabled": false | ||
}, | ||
"EngineVersion": "OpenSearch_2.11", | ||
"LogPublishingOptions": { | ||
"ES_APPLICATION_LOGS": { | ||
"CloudWatchLogsLogGroupArn": { | ||
"Fn::ImportValue": "cdkinteg-logs-resource-policy:ExportsOutputFnGetAttAppLogsGroupC90FBC0AArn7BBE8767" | ||
}, | ||
"Enabled": true | ||
} | ||
}, | ||
"NodeToNodeEncryptionOptions": { | ||
"Enabled": false | ||
} | ||
}, | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.