Skip to content

Commit

Permalink
add a test for Refs in template
Browse files Browse the repository at this point in the history
  • Loading branch information
Tietew committed Jun 13, 2023
1 parent 1c245cf commit bf88ec5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Template } from '../../assertions';
import { App, Aws, Duration, Lazy, Stack } from '../../core';
import { StringParameter } from '../../aws-ssm';
import { App, Aws, Duration, Lazy, Stack, Token } from '../../core';
import { CachePolicy, CacheCookieBehavior, CacheHeaderBehavior, CacheQueryStringBehavior } from '../lib';

describe('CachePolicy', () => {
Expand Down Expand Up @@ -166,6 +167,23 @@ describe('CachePolicy', () => {
},
});
});

test('respects Tokens', () => {
new CachePolicy(stack, 'CachePolicy', {
cachePolicyName: 'MyPolicy',
minTtl: Duration.seconds(Token.asNumber(StringParameter.valueForStringParameter(stack, '/Min'))),
defaultTtl: Duration.seconds(Token.asNumber(StringParameter.valueForStringParameter(stack, '/Default'))),
maxTtl: Duration.seconds(Token.asNumber(StringParameter.valueForStringParameter(stack, '/Max'))),
});

Template.fromStack(stack).hasResourceProperties('AWS::CloudFront::CachePolicy', {
CachePolicyConfig: {
MinTTL: { Ref: 'SsmParameterValueMinC96584B6F00A464EAD1953AFF4B05118Parameter' },
DefaultTTL: { Ref: 'SsmParameterValueDefaultC96584B6F00A464EAD1953AFF4B05118Parameter' },
MaxTTL: { Ref: 'SsmParameterValueMaxC96584B6F00A464EAD1953AFF4B05118Parameter' },
},
});
});
});
});

Expand Down

0 comments on commit bf88ec5

Please sign in to comment.