'How to remove a resource using an Aspect
This change added support for Cloudwatch Logs Resource policies.
However in GovCloud, the AWS::Logs::ResourcePolicy is not part of the cfn spec.
I know you can use Escape Hatches to override properties, but can you also directly remove a resource?
I've started an Aspect
@jsii.implements(IAspect)
class RemoveLogResourcePolicy:
def visit(self, node: IConstruct):
if (
CfnResource.is_cfn_resource(node)
and node.cfn_resource_type == "AWS::Logs::ResourcePolicy"
):
# Can I somehow delete `node` here?
Perhaps I'm over complicating it?
Solution 1:[1]
I ended up running the following Aspect:
@jsii.implements(IAspect)
class RemoveLogResourcePolicy:
def visit(self, node: IConstruct):
if isinstance(node, logs.ResourcePolicy):
node.node.try_remove_child("ResourcePolicy")
I'm only applying this aspect if deploying to Govcloud
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | maafk |
