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

(elbv2): unable to remove bucket policy dependency #31633

Closed
1 task
automartin5000 opened this issue Oct 3, 2024 · 3 comments
Closed
1 task

(elbv2): unable to remove bucket policy dependency #31633

automartin5000 opened this issue Oct 3, 2024 · 3 comments
Assignees
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 guidance Question that needs advice or information. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@automartin5000
Copy link

Describe the bug

Attempting to remove the bucket policy dependency with cfnAlb.removeDependency(cfnAccessBuckePolicy) results in the following TypeError: target.shouldSynthesize is not a function`

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Dependency is removed

Current Behavior

Test suite failed to run - TypeError: target.shouldSynthesize is not a function

Reproduction Steps

alb.logAccessLogs(accessLogBucket);
const cfnAccessLogBucketPolicy = accessLogBucket.node.findChild("Policy") as CfnBucketPolicy;
const cfnAlb = alb.node.defaultChild as CfnLoadBalancer;
cfnAlb.removeDependency(cfnAccessLogBucketPolicy);

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.160

Framework Version

No response

Node.js Version

20.11.1

OS

Mac 14.6

Language

TypeScript

Language Version

5.4.5

Other information

No response

@automartin5000 automartin5000 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 3, 2024
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Oct 3, 2024
@khushail khushail added needs-reproduction This issue needs reproduction. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Oct 4, 2024
@khushail khushail self-assigned this Oct 4, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-reproduction This issue needs reproduction. labels Oct 4, 2024
@khushail
Copy link
Contributor

khushail commented Oct 8, 2024

Hi @automartin5000 , thanks for reaching out.

The given code is giving error because the bucket policy is not identified as target.

if (!target.shouldSynthesize()) {

CFnBucketPolicy is different from BucketPolicy. You could try running this code -

    const cfnAlb = alb.node.findChild('Resource') as alb.CfnLoadBalancer
    const cfnBucket = accesslogbucket.node.findChild('Resource') as CfnBucket;
    //const cfnBucketPolicy = accesslogbucket.node.findChild('Policy') as CfnBucketPolicy;
    const cfnbucketPolicy = accesslogbucket.policy?.node.defaultChild as CfnBucketPolicy;
    cfnAlb.removeDependency(cfnbucketPolicy);

The result of cdk diff shows the policy being removed -
Screenshot 2024-10-08 at 11 44 43 AM

this should do the trick.
let me know if this does not work for you.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 8, 2024
@automartin5000
Copy link
Author

@khushail Thanks! I ended up not needing to remove the bucket policy, but that's good to know.

Copy link

github-actions bot commented Oct 8, 2024

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 Oct 8, 2024
@khushail khushail added guidance Question that needs advice or information. and removed bug This issue is a bug. labels Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 guidance Question that needs advice or information. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants