Open nagkumar opened 2 years ago
I can replicate working on it.
This particular project is just for reference and is not supposed to be able to deploy. It shows you all the various methods and approaches that you can take to perform resource overrides but most if not all of them are not valid or make sense for buckets.
Started looking at the lines that you would have to comment out or "fix" to get it working and you are left with just an S3 bucket. So adding to doc on how to make it deployable would not make sense. The stability banner already indicates that it not meant to be deployed an just be a reference.
I will leave this open for a couple days if you have some comments, otherwise I will close.
just for reference
Even as a reference, should they not work (as per the readme.md instructions) .. surprised to note these examples are not meant for developers to try out locally..
examples are the best way to speed learn CDK, experiment, and learn. Consider fix and close if that makes better sense... as a learner definitely we want to take examples as references to raise up to the next level. Getting to know what is resource override with this CDK example is the right way to self-scale.
further debugging of this example.. this example is trying to override many properties of s3 bucket, including its name
most of them are coded same exists in test*.json file
Observe resource "AWS::S3::Bucket"
changed to "AWS::S3::Bucketeer"
bucketResource.addOverride("Type", "AWS::S3::Bucketeer"); // even "Type" can be overridden
bucketResource.addOverride("Transform", "Boom");
bucketResource.addOverride("Properties.CorsConfiguration", ImmutableMap.builder()
.put("Custom", 123)
.put("Bar", ImmutableList.of("A", "B"))
.build());
// addPropertyOverride simply allows you to omit the "Properties." prefix
bucketResource.addPropertyOverride("VersioningConfiguration.Status", "NewStatus");
bucketResource.addPropertyOverride("Token", otherBucket.getBucketArn());
bucketCfnResource.addPropertyOverride(
"BucketEncryption.ServerSideEncryptionConfiguration.0.EncryptEverythingAndAlways", true);
Kind of error I could see are
Stack Deployments Failed: Error: The stack named res-override failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Encountered unsupported property EncryptEverythingAndAlways
(MyBucketF68F3FF0) Encountered unsupported property Custom
Token
Transform
As mentioned earlier by @kaizio this example is specifically to display the over-write capabilities and to show that any CF property can be over-written (even the invalid ones) and no validation happens till deployment is triggered. So if you try to perform cdk synth with invalid properties set in cdk code it would succeed. But cdk deploy would fail, This example demonstrates that validations of over written properties are done during deployment but not during the creation of cfn template. Thus in ReadMe also this example is marked as reference only. The above error during cdk deploy is expected behaviour of the example as per comments in the code ` private void modifyPropertiesExample(Bucket bucket) { CfnBucket bucketCfnResource = (CfnBucket) bucket.getNode().getDefaultChild();
// This is an invalid CF property, but there is no validation at this point, so anything can be
// set.
// This is just to show that anything can be set at this point, but it's only validated ones the
// stack
// is being deployed to CloudFormation.
bucketCfnResource.addPropertyOverride(
"BucketEncryption.ServerSideEncryptionConfiguration.0.EncryptEverythingAndAlways", true);
// This is a valid CF property
bucketCfnResource.addPropertyDeletionOverride(
"BucketEncryption.ServerSideEncryptionConfiguration.0.ServerSideEncryptionByDefault");
}`
Describe the bug
https://github.com/aws-samples/aws-cdk-examples/tree/master/java/resource-overrides
fails to deploy
Expected Behavior
example should not fail
Current Behavior
[100%] success: Published fc5f710b126aed0a3bbb1646eb78a6ae7f2c074e4f6b717bbf006512fe5a2f6a:current_account-current_region Call failed: describeStacks({"StackName":"resource-overrides"}) => Stack with id resource-overrides does not exist (code=ValidationError) resource-overrides: checking if we can skip deploy resource-overrides: no existing stack resource-overrides: deploying... Attempting to create ChangeSet with name cdk-deploy-change-set to create stack resource-overrides resource-overrides: creating CloudFormation changeset... Call failed: createChangeSet({"StackName":"resource-overrides","ChangeSetName":"cdk-deploy-change-set","ChangeSetType":"CREATE","Description":"CDK Changeset for execution 22b4d6a1-9a77-406b-b3f3-0030ad663f13","TemplateURL":"https://s3.ap-south-1.amazonaws.com/cdk-hnb659fds-assets-132462119873-ap-south-1/fc5f710b126aed0a3bbb1646eb78a6ae7f2c074e4f6b717bbf006512fe5a2f6a.json","Parameters":[],"RoleARN":"arn:aws:iam::132462119873:role/cdk-hnb659fds-cfn-exec-role-132462119873-ap-south-1","Capabilities":["CAPABILITY_IAM","CAPABILITY_NAMED_IAM","CAPABILITY_AUTO_EXPAND"],"Tags":[]}) => Invalid template resource property 'Transform' (code=ValidationError)
❌ resource-overrides failed: Error [ValidationError]: Invalid template resource property 'Transform' at Request.extractError (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\protocol\query.js:50:29) at Request.callListeners (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\sequential_executor.js:106:20) at Request.emit (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\sequential_executor.js:78:10) at Request.emit (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\request.js:686:14) at Request.transition (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\request.js:22:10) at AcceptorStateMachine.runTo (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\state_machine.js:14:12) at d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\state_machine.js:26:10 at Request. (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\request.js:688:12)
at Request.callListeners (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-sdk\lib\sequential_executor.js:116:18) {
code: 'ValidationError',
time: 2022-09-26T11:57:17.386Z,
requestId: 'ae5d78d4-2e3d-4ddf-be04-e6b5a37e03c8',
statusCode: 400,
retryable: false,
retryDelay: 393.72874138335766
}
❌ Deployment failed: Error: Stack Deployments Failed: ValidationError: Invalid template resource property 'Transform' at deployStacks (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\deploy.ts:61:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at CdkToolkit.deploy (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:312:7) at initCommandLine (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cli.ts:349:12) Reading cached notices from C:\Users\Raja Nagendra Kumar.cdk\cache\notices.json Stack Deployments Failed: ValidationError: Invalid template resource property 'Transform' Error: Stack Deployments Failed: ValidationError: Invalid template resource property 'Transform' at deployStacks (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\deploy.ts:61:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at CdkToolkit.deploy (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cdk-toolkit.ts:312:7) at initCommandLine (d:\Apps\Dev\langs\scripting\js\Node\18.x\18.9.0\node_modules\aws-cdk\lib\cli.ts:349:12) [INFO] Scanning for projects...
Reproduction Steps
cdk deploy
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.43.1
Framework Version
No response
Node.js Version
18
OS
win10
Language
Java
Language Version
No response