Skip to content

Commit

Permalink
feat: support the 'Description' resource attribute (#10522)
Browse files Browse the repository at this point in the history
One more resource attribute that we missed,
and that is needed for cfn-include to be able to handle ingesting all templates.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
skinny85 authored Sep 26, 2020
1 parent 6a24026 commit d68ce2f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ export class CfnInclude extends core.CfnElement {

// fail early for resource attributes we don't support yet
const knownAttributes = [
'Type', 'Properties', 'Condition', 'DependsOn', 'Metadata', 'Version',
'CreationPolicy', 'UpdatePolicy', 'DeletionPolicy', 'UpdateReplacePolicy',
'Condition', 'DependsOn', 'Description', 'Metadata', 'Properties', 'Type', 'Version',
'CreationPolicy', 'DeletionPolicy', 'UpdatePolicy', 'UpdateReplacePolicy',
];
for (const attribute of Object.keys(resourceAttributes)) {
if (!knownAttributes.includes(attribute)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"CustomResource": {
"Type": "AWS::CloudFormation::CustomResource",
"Description": "some random custom resource",
"Properties": {
"ServiceToken": "CustomValue",
"CustomFuncProp": {
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/core/lib/cfn-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export class CfnParser {
cfnOptions.deletionPolicy = this.parseDeletionPolicy(resourceAttributes.DeletionPolicy);
cfnOptions.updateReplacePolicy = this.parseDeletionPolicy(resourceAttributes.UpdateReplacePolicy);
cfnOptions.version = this.parseValue(resourceAttributes.Version);
cfnOptions.description = this.parseValue(resourceAttributes.Description);
cfnOptions.metadata = this.parseValue(resourceAttributes.Metadata);

// handle Condition
Expand Down
9 changes: 9 additions & 0 deletions packages/@aws-cdk/core/lib/cfn-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export class CfnResource extends CfnRefElement {
UpdateReplacePolicy: capitalizePropertyNames(this, this.cfnOptions.updateReplacePolicy),
DeletionPolicy: capitalizePropertyNames(this, this.cfnOptions.deletionPolicy),
Version: this.cfnOptions.version,
Description: this.cfnOptions.description,
Metadata: ignoreEmpty(this.cfnOptions.metadata),
Condition: this.cfnOptions.condition && this.cfnOptions.condition.logicalId,
}, props => {
Expand Down Expand Up @@ -438,6 +439,14 @@ export interface ICfnResourceOptions {
*/
version?: string;

/**
* The description of this resource.
* Used for informational purposes only, is not processed in any way
* (and stays with the CloudFormation template, is not passed to the underlying resource,
* even if it does have a 'description' property).
*/
description?: string;

/**
* Metadata associated with the CloudFormation resource. This is not the same as the construct metadata which can be added
* using construct.addMetadata(), but would not appear in the CloudFormation template automatically.
Expand Down

0 comments on commit d68ce2f

Please sign in to comment.