aws-docdbelastic: Unable to update security group
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### 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:
```typescript
/**
* 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:
```bash
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_
Contributor guide
Research direction
Start with the aws_docdbelastic.CfnCluster usage in the reproduction, especially vpcSecurityGroupIds, and reproduce the update with the CDK CLI version shown. Compare the generated CDK diff with the DocDB Elastic service error; done means a security-group-only update deploys without the conflicting-parameter failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100