Skip to content

Commit

Permalink
fix: fix resource overrides example (aws-samples#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoManyHs authored and rix0rrr committed Apr 16, 2019
1 parent c66666e commit 0d81bfc
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions typescript/resource-overrides/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,13 @@ class ResourceOverridesExample extends cdk.Stack {
Bar: [ 'A', 'B' ]
});

// addPropertyOverrides simply allows you to omit the "Properties." prefix
// addPropertyOverride simply allows you to omit the "Properties." prefix
bucketResource.addPropertyOverride('VersioningConfiguration.Status', 'NewStatus');
bucketResource.addPropertyOverride('Foo', null);
// bucketResource.addPropertyOverride('Foo', null); // FIXME causes filterUndefined to error
bucketResource.addPropertyOverride('Token', otherBucket.bucketArn); // use tokens
bucketResource.addPropertyOverride('LoggingConfiguration.DestinationBucketName', otherBucket.bucketName);

//
// It is also possible to request a deletion of a value by either assigning
// `undefined` (in supported languages) or use the `addDeletionOverride` method
//

bucketResource.addDeletionOverride('Metadata');
bucketResource.addPropertyDeletionOverride('CorsConfiguration.Bar');

//
// It is also possible to specify overrides via a strong-typed property
// bag called `propertyOverrides`
//

bucketResource.propertyOverrides.analyticsConfigurations = [
bucketResource.addPropertyOverride('AnalyticsConfigurations', [
{
id: 'config1',
storageClassAnalysis: {
Expand All @@ -82,16 +69,22 @@ class ResourceOverridesExample extends cdk.Stack {
}
}
}
];
]);

bucketResource.propertyOverrides.corsConfiguration = {
corsRules: [
{
allowedMethods: [ 'GET' ],
allowedOrigins: [ '*' ]
}
]
};
bucketResource.addPropertyOverride('CorsConfiguration.CorsRules', [
{
AllowedMethods: [ 'GET' ],
AllowedOrigins: [ '*' ]
}
]);

//
// It is also possible to request a deletion of a value by either assigning
// `undefined` (in supported languages) or use the `addDeletionOverride` method
//

bucketResource.addDeletionOverride('Metadata');
bucketResource.addPropertyDeletionOverride('CorsConfiguration.Bar');

const vpc = new ec2.VpcNetwork(this, 'VPC', { maxAZs: 1 });
const asg = new autoscaling.AutoScalingGroup(this, 'ASG', {
Expand All @@ -113,4 +106,4 @@ class ResourceOverridesExample extends cdk.Stack {

const app = new cdk.App();
new ResourceOverridesExample(app, 'resource-overrides');
app.run();
app.run();

0 comments on commit 0d81bfc

Please sign in to comment.