-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(cli): format of tags in cdk.json is not validated, easy to get wrong #20854
Comments
For reference the replacement cdk.json is. {
"app": "npx ts-node --prefer-ts-exts bin/hello-cdk.ts",
"context": {
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:stackRelativeExports": true,
"@aws-cdk/core:target-partitions": ["aws"],
"@aws-cdk/core:validateSnapshotRemovalPolicy": true
},
"tags": {
"Tag1": "value1",
"Tag2": "value2"
},
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
}
} |
This is sorely underdocumented, and if I were you I would put the tags in the CDK App rather than in the CLI config, but for reference the format of the tag field needs to be: {
"tags": [
{
"Key": "...",
"Value": "..."
}
]
} |
If tags is present in cdk.json, validate that it is an array of objects, and each object has a Tag string and a Value string. If tags is not structurally valid `cdk bootstrap` and `cdk deploy` fail with an error. `tags must be an array of { Tag: string, Value: string } objects` There is no attempt to validate the strings of each Tag and Value beyond that they are strings. closes #20854 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
If tags is present in cdk.json, validate that it is an array of objects, and each object has a Tag string and a Value string. If tags is not structurally valid `cdk bootstrap` and `cdk deploy` fail with an error. `tags must be an array of { Tag: string, Value: string } objects` There is no attempt to validate the strings of each Tag and Value beyond that they are strings. closes aws#20854 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
After adding tags to the local cdk.json,
cdk deploy
fails with anInvalidParameterType: Expected params.Tags to be an Array
from aws-sdk.Expected Behavior
The synthesized template deploys with the tags in cdk.json.
Current Behavior
Reproduction Steps
mkdir hello-cdk
cd hello-cdk
cdk init app --language typescript
cdk deploy
So far this works.
cdk deploy
This fails.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.29.0 (build 47d7ec4)
Framework Version
No response
Node.js Version
v16.15.1
OS
macOS 12.4 arm64
Language
Typescript
Language Version
4.7.4
Other information
Documentation reference: https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-config
The text was updated successfully, but these errors were encountered: