Skip to content

Commit aa61dfb

Browse files
moofish32Elad Ben-Israel
authored andcommitted
feat(cdk): Expose props in CFN resources and remove propertyOverrides (#2372) (#2372)
Modify the generation of CFN resources to create Class members for each CloudFormation Property. This removes the need for the property override solution implemented previously. CloudFormation Resource attributes are now prefixed with `attr` instead of resource name. The RefKind patches are removed. All L2 resources have been updated to consume the new attribute names. The Ref attributes are removed and the new `refAsString` is used. Added tagging support for AppSync, AppMesh, StepFunctions. Token now supports `number` types, so the generated code no longer treats number as non-tokenizable. Fixes #2100 BREAKING CHANGE: All L1 ("Cfn") Resources attributes are now prefixed with `attr` instead of the resource type. For example, in S3 `bucket.bucketArn` is now `bucket.attrArn`. * `propertyOverrides` has been removed from all "Cfn" resources, instead users can now read/write resource properties directly on the resource class. For example, instead of `lambda.propertyOverrides.runtime` just use `lambda.runtime`.
1 parent be574a1 commit aa61dfb

File tree

90 files changed

+417
-5352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+417
-5352
lines changed

packages/@aws-cdk/aws-apigateway/lib/deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class Deployment extends Resource {
7676
}
7777

7878
this.api = props.api;
79-
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.deploymentId });
79+
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.refAsString });
8080
}
8181

8282
/**

packages/@aws-cdk/aws-apigateway/lib/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export class Resource extends ResourceBase {
211211
};
212212
const resource = new CfnResource(this, 'Resource', resourceProps);
213213

214-
this.resourceId = resource.resourceId;
214+
this.resourceId = resource.refAsString;
215215
this.restApi = props.parent.restApi;
216216

217217
// render resource path (special case for root)

packages/@aws-cdk/aws-apigateway/lib/restapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class RestApi extends Resource implements IRestApi {
228228
this.configureCloudWatchRole(resource);
229229
}
230230

231-
this.root = new RootResource(this, props, resource.restApiRootResourceId);
231+
this.root = new RootResource(this, props, resource.attrRootResourceId);
232232
}
233233

234234
/**

packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export class VpcLink extends Resource {
4545
targetArns: props.targets.map(nlb => nlb.loadBalancerArn)
4646
});
4747

48-
this.vpcLinkId = cfnResource.vpcLinkId;
48+
this.vpcLinkId = cfnResource.refAsString;
4949
}
50-
}
50+
}

packages/@aws-cdk/aws-apigateway/test/test.resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,4 @@ export = {
286286

287287
}
288288
}
289-
};
289+
};

packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class ScalableTarget extends Resource implements IScalableTarget {
119119
serviceNamespace: props.serviceNamespace
120120
});
121121

122-
this.scalableTargetId = resource.scalableTargetId;
122+
this.scalableTargetId = resource.refAsString;
123123
}
124124

125125
/**
@@ -269,4 +269,4 @@ export enum ServiceNamespace {
269269
* Custom Resource
270270
*/
271271
CustomResource = 'custom-resource',
272-
}
272+
}

packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class StepScalingAction extends cdk.Construct {
9393
} as CfnScalingPolicy.StepScalingPolicyConfigurationProperty
9494
});
9595

96-
this.scalingPolicyArn = resource.scalingPolicyArn;
96+
this.scalingPolicyArn = resource.refAsString;
9797
}
9898

9999
/**
@@ -190,4 +190,4 @@ export interface AdjustmentTier {
190190
* @default +Infinity
191191
*/
192192
readonly upperBound?: number;
193-
}
193+
}

packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
141141
}
142142
});
143143

144-
this.scalingPolicyArn = resource.scalingPolicyArn;
144+
this.scalingPolicyArn = resource.refAsString;
145145
}
146146
}
147147

@@ -171,4 +171,4 @@ export enum PredefinedMetric {
171171
SageMakerVariantInvocationsPerInstance = 'SageMakerVariantInvocationsPerInstance',
172172
ECSServiceAverageCPUUtilization = 'ECSServiceAverageCPUUtilization',
173173
ECSServiceAverageMemoryUtilization = 'ECSServiceAverageMemoryUtilization',
174-
}
174+
}

packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
442442

443443
this.autoScalingGroup = new CfnAutoScalingGroup(this, 'ASG', asgProps);
444444
this.osType = machineImage.os.type;
445-
this.autoScalingGroupName = this.autoScalingGroup.autoScalingGroupName;
445+
this.autoScalingGroupName = this.autoScalingGroup.refAsString;
446446
this.autoScalingGroupArn = Stack.of(this).formatArn({
447447
service: 'autoscaling',
448448
resource: 'autoScalingGroup:*:autoScalingGroupName',

packages/@aws-cdk/aws-autoscaling/lib/lifecycle-hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class LifecycleHook extends Resource implements ILifecycleHook {
116116
// lifecycle hook.
117117
resource.node.addDependency(this.role);
118118

119-
this.lifecycleHookName = resource.lifecycleHookName;
119+
this.lifecycleHookName = resource.refAsString;
120120
}
121121
}
122122

0 commit comments

Comments
 (0)