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

aws-docdbelastic: Unable to update security group #29097

Open
Exter-dg opened this issue Feb 14, 2024 · 3 comments
Open

aws-docdbelastic: Unable to update security group #29097

Exter-dg opened this issue Feb 14, 2024 · 3 comments
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@Exter-dg
Copy link

Exter-dg commented Feb 14, 2024

Describe the bug

When updating the security group in docdbElasticCluster, CDK throws an error -

DocumentDBStack failed: Error: The stack named DocumentDBStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Shard configuration, network parameters (security groups and subnets) and Authentication parameters (secret ARN and password) cannot be modified at the same time. (Service: DocDbElastic, Status Code: 400, Request ID: 53edd146-bc75-40b6-a756-af6df4d019c2)" (RequestToken: c4d30044-c9c1-2ec2-24d2-ed5bde5784e9, HandlerErrorCode: InvalidRequest)

Earlier I used to pass a SG ARN manually.
Now, we create a new security group in the same stack.

New Code:

/**
 * Create a new Security Group
 * https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SecurityGroup.html
 */
const securityGroup = new ec2.SecurityGroup(this, 'docDbSG', {
  vpc: vpc,
});

// Add ingress rules
securityGroup.addIngressRule(ec2.Peer.ipv4("10.0.0.0/8"), ec2.Port.allTraffic(), "allow from internal network");

/**
 * Create a new Document DB Elastic Cluster
 * https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_docdbelastic.CfnCluster.html
 */
new docdbelastic.CfnCluster(this, 'elasticDocDbCluster', {
  adminUserName: props!.docDbAdminUserName,
  adminUserPassword: "password",
  authType: props!.docDbAuthType,
  clusterName: props!.docDbClusterName,
  shardCapacity: props!.docDbShardCapacity,
  shardCount: props!.docDbShardCount,
  subnetIds: props!.dataSubnets,
  vpcSecurityGroupIds: [securityGroup.securityGroupId],
});

CDK Diff only shows that the security group is being updated:

Resources
[+] AWS::EC2::SecurityGroup docDbSG docDbSGDD5902
[~] AWS::DocDBElastic::Cluster elasticDocDbCluster elasticDocDbCluster
 └─ [~] VpcSecurityGroupIds
     └─ @@ -1,3 +1,8 @@
        [ ] [
        [-]   "sg-1234"
        [+]   {
        [+]     "Fn::GetAtt": [
        [+]       "docDbSGDD5902",
        [+]       "GroupId"
        [+]     ]
        [+]   }
        [ ] ]

Expected Behavior

SG should be updated

Current Behavior

Throws error

Reproduction Steps

Code

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.123.0

Framework Version

No response

Node.js Version

v16.20.2

OS

Linux/UNIX

Language

TypeScript

Language Version

No response

Other information

No response

@Exter-dg Exter-dg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 14, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Feb 14, 2024
@Exter-dg Exter-dg changed the title aws_docdbelastic: Unable to update security group aws-docdbelastic: Unable to update security group Feb 14, 2024
@pahud
Copy link
Contributor

pahud commented Feb 14, 2024

I guess its the restrict from cloudformation that does not allow you to update that in the same time and you need to create a new security group instead.

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 14, 2024
@Exter-dg
Copy link
Author

@pahud So what's the workaround? I even tried creating the security group first and then trying to add it to docdb cluster. It still throws the same error

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 16, 2024
@Exter-dg
Copy link
Author

Exter-dg commented Feb 26, 2024

Temporary workaround: I removed the SG association with DocDB and manually ran the stack. This created the new SG. Later on, I manually added this SG to our DocDB cluster from AWS console. I again updated our code to its original state - attaching the SG to our docdb cluster using CDK. When it was deployed again, it ran without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants