ec2.CfnTransitGateway: The request must modify any of the Transit Gateway parameters
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
When tried creating the TransitGateway using the following code, the deployment is successful.
```
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
interface TypescriptStackProps extends cdk.StackProps {
}
export class TypescriptStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: TypescriptStackProps) {
super(scope, id, props);
const transitGateway = new ec2.CfnTransitGateway(this, 'MyTransitGateway');
}
}
```
In the next run of cdk deploy, the only change made was to add the tags at stack level, using the below piece of line in the "/bin/typescript.ts" file.
```
cdk.Tags.of(ts).add('Env', 'Production');
```
Adding the above line results into the following error.
```
The request must modify any of the Transit Gateway parameters (Service: Ec2, Status Code: 400, Request ID: xxxx) (SDK Attempt Count: 1)" (RequestToken: xxxx, HandlerErrorCode: InvalidRequest)
```
On checking the Cloud Trail events, I could see a ModifyTransitGateway was being called, which is not expected, as it should have called CreateTags API call.
When using props in the transit gateway creation, and not relying on the default values of the L1 construct, and following the same steps as mentioned above, the error doesn't occur.
```
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
interface TypescriptStackProps extends cdk.StackProps {
}
export class TypescriptStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: TypescriptStackProps) {
super(scope, id, props);
const transitGateway = new ec2.CfnTransitGateway(this, 'MyTransitGateway', {
autoAcceptSharedAttachments: 'disable', // Whether to automatically accept cross-account attachments
});
}
}
```
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
It should not fail when using the default values of the L1 construct
### Current Behavior
Fails with the following error.
```
The request must modify any of the Transit Gateway parameters (Service: Ec2, Status Code: 400, Request ID: xxxx) (SDK Attempt Count: 1)" (RequestToken: xxxx, HandlerErrorCode: InvalidRequest)
```
### Reproduction Steps
When tried creating the TransitGateway using the following code, the deployment is successful.
```
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
interface TypescriptStackProps extends cdk.StackProps {
}
export class TypescriptStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: TypescriptStackProps) {
super(scope, id, props);
const transitGateway = new ec2.CfnTransitGateway(this, 'MyTransitGateway');
}
}
```
In the next run of cdk deploy, the only change made was to add the tags at stack level, using the below piece of line in the "/bin/typescript.ts" file.
```
cdk.Tags.of(ts).add('Env', 'Production');
```
Adding the above line results into the following error.
```
The request must modify any of the Transit Gateway parameters (Service: Ec2, Status Code: 400, Request ID: xxxx) (SDK Attempt Count: 1)" (RequestToken: xxxx, HandlerErrorCode: InvalidRequest)
```
On checking the Cloud Trail events, I could see a ModifyTransitGateway was being called, which is not expected, as it should have called CreateTags API call.
When using props in the transit gateway creation, and not relying on the default values of the L1 construct, and following the same steps as mentioned above, the error doesn't occur.
```
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
interface TypescriptStackProps extends cdk.StackProps {
}
export class TypescriptStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: TypescriptStackProps) {
super(scope, id, props);
const transitGateway = new ec2.CfnTransitGateway(this, 'MyTransitGateway', {
autoAcceptSharedAttachments: 'disable', // Whether to automatically accept cross-account attachments
});
}
}
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.162.0
### AWS CDK CLI version
2.1007.0
### Node.js Version
v22.9.0
### OS
MacOs
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start by reproducing the deployment with ec2.CfnTransitGateway using default properties, then add cdk.Tags.of(ts).add('Env', 'Production') in /bin/typescript.ts and compare the CloudTrail calls. Check why stack-level tags lead to ModifyTransitGateway instead of CreateTags, and verify that the deployment succeeds without specifying transit gateway properties.
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
- 35/100