diff --git a/CHANGELOG.md b/CHANGELOG.md index c6a19b6edba20..6b54895aee553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,36 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.56.0](https://github.com/aws/aws-cdk/compare/v1.55.0...v1.56.0) (2020-07-31) + + +### ⚠ BREAKING CHANGES + +* **appsync:** **appsync** prop `schemaDefinition` no longer takes string, instead it is required to configure schema definition mode. +- **appsync**: schemaDefinition takes param `SchemaDefinition.XXX` to declare how schema will be configured + - **SchemaDefinition.CODE** allows schema definition through CDK + - **SchemaDefinition.FILE** allows schema definition through schema.graphql file +* **cloudfront:** Removed origin classes from the aws-cloudfront module. +* **aws-cloudfront:** Removed S3Origin and HttpOrigin from the aws-cloudfront module. Use the S3Origin and HttpOrigin classes in the aws-cloudfront-origins module instead. +* **aws-cloudfront:** Renamed Origin to OriginBase. +* **cloudfront:** the property Origin.domainName has been removed + +### Features + +* **cfn-include:** add support for the Fn::Sub function ([#9275](https://github.com/aws/aws-cdk/issues/9275)) ([2a48495](https://github.com/aws/aws-cdk/commit/2a48495093dc33d88554aaa0a033338e798f9d5f)) +* **core:** make the CfnParameter class mutable ([#9365](https://github.com/aws/aws-cdk/issues/9365)) ([860966a](https://github.com/aws/aws-cdk/commit/860966a3945e1b667f92b19b49b92f7a1b1b8b33)), closes [#9364](https://github.com/aws/aws-cdk/issues/9364) + + +### Bug Fixes + +* **certificatemanager:** DNS validation for wildcard certificates ([#9291](https://github.com/aws/aws-cdk/issues/9291)) ([419278b](https://github.com/aws/aws-cdk/commit/419278bf88c16d5519ba63c822e4af52157e8c67)), closes [#9248](https://github.com/aws/aws-cdk/issues/9248) +* **pipelines:** reduce assets IAM policy size ([#9333](https://github.com/aws/aws-cdk/issues/9333)) ([88d563f](https://github.com/aws/aws-cdk/commit/88d563fab6971c20754d76c5d2eb9f4463aeae6c)), closes [#9316](https://github.com/aws/aws-cdk/issues/9316) + + +* **appsync:** strongly type schema definition mode ([#9283](https://github.com/aws/aws-cdk/issues/9283)) ([b46aa99](https://github.com/aws/aws-cdk/commit/b46aa998ce3aedd3c5cfc5b4eef08859a6dc0d2a)), closes [#9301](https://github.com/aws/aws-cdk/issues/9301) +* **cloudfront:** README updates and notes of breaking changes ([#9356](https://github.com/aws/aws-cdk/issues/9356)) ([fbb0418](https://github.com/aws/aws-cdk/commit/fbb04183ea77bcf630c39fa22893039865782a12)), closes [#9326](https://github.com/aws/aws-cdk/issues/9326) +* **cloudfront:** small refactoring of the Origin API ([#9281](https://github.com/aws/aws-cdk/issues/9281)) ([cbfdc15](https://github.com/aws/aws-cdk/commit/cbfdc15959c5d5209d4fed6ac281f9897f44d4c5)), closes [#9109](https://github.com/aws/aws-cdk/issues/9109) + ## [1.55.0](https://github.com/aws/aws-cdk/compare/v1.54.0...v1.55.0) (2020-07-28) diff --git a/lerna.json b/lerna.json index 0a38efa354fad..855e51ed977ca 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "tools/*" ], "rejectCycles": "true", - "version": "1.55.0" + "version": "1.56.0" } diff --git a/packages/@aws-cdk/aws-cloudfront-origins/package.json b/packages/@aws-cdk/aws-cloudfront-origins/package.json index df97c4987294f..c67cc58d43705 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/package.json +++ b/packages/@aws-cdk/aws-cloudfront-origins/package.json @@ -63,6 +63,7 @@ "license": "Apache-2.0", "devDependencies": { "@aws-cdk/assert": "0.0.0", + "@aws-cdk/aws-ec2": "0.0.0", "aws-sdk": "^2.715.0", "cdk-build-tools": "0.0.0", "cdk-integ-tools": "0.0.0", diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.expected.json b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.expected.json new file mode 100644 index 0000000000000..c5f7da26599c6 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.expected.json @@ -0,0 +1,28 @@ +{ + "Resources": { + "DistributionCFDistribution882A7313": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "DefaultCacheBehavior": { + "ForwardedValues": { + "QueryString": false + }, + "TargetOriginId": "cloudfronthttporiginDistributionOrigin162B02709", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "Origins": [ + { + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only" + }, + "DomainName": "www.example.com", + "Id": "cloudfronthttporiginDistributionOrigin162B02709" + } + ] + } + } + } + } +} diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.ts new file mode 100644 index 0000000000000..8806ca3aafdc4 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.http-origin.ts @@ -0,0 +1,13 @@ +import * as cloudfront from '@aws-cdk/aws-cloudfront'; +import * as cdk from '@aws-cdk/core'; +import * as origins from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'cloudfront-http-origin'); + +new cloudfront.Distribution(stack, 'Distribution', { + defaultBehavior: { origin: new origins.HttpOrigin('www.example.com') }, +}); + +app.synth(); diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.expected.json b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.expected.json new file mode 100644 index 0000000000000..8c97abc155066 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.expected.json @@ -0,0 +1,433 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc" + } + ] + } + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "10.0.0.0/18", + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1a", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "10.0.64.0/18", + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1b", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet2EIP3C605A87": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2NATGateway9182C01D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "10.0.128.0/18", + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1a", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "CidrBlock": "10.0.192.0/18", + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1b", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + } + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cloudfront-load-balancer-origin/Vpc" + } + ] + } + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "LB8A12904C": { + "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", + "Properties": { + "Scheme": "internet-facing", + "SecurityGroups": [ + { + "Fn::GetAtt": [ + "LBSecurityGroup8A41EA2B", + "GroupId" + ] + } + ], + "Subnets": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "Type": "application" + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet2DefaultRoute97F91067" + ] + }, + "LBSecurityGroup8A41EA2B": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "Automatically created Security Group for ELB cloudfrontloadbalanceroriginLB8CFBA9DF", + "SecurityGroupEgress": [ + { + "CidrIp": "255.255.255.255/32", + "Description": "Disallow all traffic", + "FromPort": 252, + "IpProtocol": "icmp", + "ToPort": 86 + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "DistributionCFDistribution882A7313": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "DefaultCacheBehavior": { + "ForwardedValues": { + "QueryString": false + }, + "TargetOriginId": "cloudfrontloadbalanceroriginDistributionOrigin1BCC75186", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "Origins": [ + { + "CustomOriginConfig": { + "OriginProtocolPolicy": "https-only" + }, + "DomainName": { + "Fn::GetAtt": [ + "LB8A12904C", + "DNSName" + ] + }, + "Id": "cloudfrontloadbalanceroriginDistributionOrigin1BCC75186" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.ts new file mode 100644 index 0000000000000..85685500993ae --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.load-balancer-origin.ts @@ -0,0 +1,17 @@ +import * as cloudfront from '@aws-cdk/aws-cloudfront'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; +import * as cdk from '@aws-cdk/core'; +import * as origins from '../lib'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'cloudfront-load-balancer-origin'); + +const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 }); +const loadbalancer = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc, internetFacing: true }); + +new cloudfront.Distribution(stack, 'Distribution', { + defaultBehavior: { origin: new origins.LoadBalancerV2Origin(loadbalancer) }, +}); + +app.synth(); diff --git a/packages/@aws-cdk/cloudformation-include/README.md b/packages/@aws-cdk/cloudformation-include/README.md index 0e08b7f5fb745..1d79c7cbf09cc 100644 --- a/packages/@aws-cdk/cloudformation-include/README.md +++ b/packages/@aws-cdk/cloudformation-include/README.md @@ -110,6 +110,24 @@ Note that [Custom Resources](https://docs.aws.amazon.com/AWSCloudFormation/lates will be of type CfnResource, and hence won't need to be casted. This holds for any resource that isn't in the CloudFormation schema. +## Parameters + +If your template uses [CloudFormation Parameters] (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html), +you can retrieve them from your template: + +```typescript +import * as core from '@aws-cdk/core'; + +const param: core.CfnParameter = cfnTemplate.getParameter('MyParameter'); +``` + +The `CfnParameter` object is mutable, +and any changes you make to it will be reflected in the resulting template: + +```typescript +param.default = 'MyDefault'; +``` + ## Conditions If your template uses [CloudFormation Conditions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html), @@ -172,7 +190,6 @@ where the child template pointed to by `https://my-s3-template-source.s3.amazona "Resources": { "MyBucket": { "Type": "AWS::S3::Bucket" - } } } } diff --git a/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts b/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts index 07529248be53b..329cda9e759c8 100644 --- a/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts @@ -397,6 +397,52 @@ describe('CDK Include', () => { }).toThrow(/Parameter with name 'FakeBucketNameThatDoesNotExist' was not found in the template/); }); + test('reflects changes to a retrieved CfnParameter object in the resulting template', () => { + const cfnTemplate = includeTestTemplate(stack, 'bucket-with-parameters.json'); + const stringParam = cfnTemplate.getParameter('BucketName'); + const numberParam = cfnTemplate.getParameter('CorsMaxAge'); + + stringParam.default = 'MyDefault'; + stringParam.allowedPattern = '[0-9]*$'; + stringParam.allowedValues = ['123123', '456789']; + stringParam.constraintDescription = 'MyNewConstraint'; + stringParam.description = 'a string of numeric characters'; + stringParam.maxLength = 6; + stringParam.minLength = 2; + + numberParam.maxValue = 100; + numberParam.minValue = 4; + numberParam.noEcho = false; + numberParam.type = "NewType"; + const originalTemplate = loadTestFileToJsObject('bucket-with-parameters.json'); + + expect(stack).toMatchTemplate({ + "Resources": { + ...originalTemplate.Resources, + }, + "Parameters": { + ...originalTemplate.Parameters, + "BucketName": { + ...originalTemplate.Parameters.BucketName, + "Default": "MyDefault", + "AllowedPattern": "[0-9]*$", + "AllowedValues": [ "123123", "456789" ], + "ConstraintDescription": "MyNewConstraint", + "Description": "a string of numeric characters", + "MaxLength": 6, + "MinLength": 2, + }, + "CorsMaxAge": { + ...originalTemplate.Parameters.CorsMaxAge, + "MaxValue": 100, + "MinValue": 4, + "NoEcho": false, + "Type": "NewType", + }, + }, + }); + }); + test('reflects changes to a retrieved CfnCondition object in the resulting template', () => { const cfnTemplate = includeTestTemplate(stack, 'resource-attribute-condition.json'); const alwaysFalseCondition = cfnTemplate.getCondition('AlwaysFalseCond'); diff --git a/packages/@aws-cdk/core/lib/cfn-output.ts b/packages/@aws-cdk/core/lib/cfn-output.ts index 387c5216ead91..3f2784f890073 100644 --- a/packages/@aws-cdk/core/lib/cfn-output.ts +++ b/packages/@aws-cdk/core/lib/cfn-output.ts @@ -60,61 +60,57 @@ export class CfnOutput extends CfnElement { } /** - * Returns the description of this Output + * A String type that describes the output value. + * The description can be a maximum of 4 K in length. + * + * @default - No description. */ public get description() { return this._description; } - /** - * Sets this output's description to the parameter - * @param description the description to update this Output's description to - */ public set description(description: string | undefined) { this._description = description; } /** - * Returns the value of this Output + * The value of the property returned by the aws cloudformation describe-stacks command. + * The value of an output can include literals, parameter references, pseudo-parameters, + * a mapping value, or intrinsic functions. */ public get value() { return this._value; } - /** - * Sets this output's value to the parameter - * @param value the value to update this Output's value to - */ public set value(value: any) { this._value = value; } /** - * Returns the condition of this Output + * A condition to associate with this output value. If the condition evaluates + * to `false`, this output value will not be included in the stack. + * + * @default - No condition is associated with the output. */ public get condition() { return this._condition; } - /** - * Sets this output's condition to the parameter - * @param condition the condition to update this Output's condition to - */ public set condition(condition: CfnCondition | undefined) { this._condition = condition; } /** - * Returns the export of this Output + * The name used to export the value of this output across stacks. + * + * To import the value from another stack, use `Fn.importValue(exportName)`. + * + * @default - the output is not exported */ public get exportName() { return this._exportName; } - /** - * Sets this output's export to the parameter - * @param exportName the export to update this Output's export to - */ public set exportName(exportName: string | undefined) { this._exportName = exportName; } diff --git a/packages/@aws-cdk/core/lib/cfn-parameter.ts b/packages/@aws-cdk/core/lib/cfn-parameter.ts index 8d91f7c006777..6226f451c2fb8 100644 --- a/packages/@aws-cdk/core/lib/cfn-parameter.ts +++ b/packages/@aws-cdk/core/lib/cfn-parameter.ts @@ -97,7 +97,17 @@ export interface CfnParameterProps { * update a stack. */ export class CfnParameter extends CfnElement { - private readonly type: string; + private _type: string; + private _default?: any; + private _allowedPattern?: string; + private _allowedValues?: string[]; + private _constraintDescription?: string; + private _description?: string; + private _maxLength?: number; + private _maxValue?: number; + private _minLength?: number; + private _minValue?: number; + private _noEcho?: boolean; /** * Creates a parameter construct. @@ -107,17 +117,165 @@ export class CfnParameter extends CfnElement { * @param scope The parent construct. * @param props The parameter properties. */ - constructor(scope: Construct, id: string, private readonly props: CfnParameterProps = {}) { + constructor(scope: Construct, id: string, props: CfnParameterProps = {}) { super(scope, id); - this.type = props.type || 'String'; + this._type = props.type || 'String'; + this._default = props.default; + this._allowedPattern = props.allowedPattern; + this._allowedValues = props.allowedValues; + this._constraintDescription = props.constraintDescription; + this._description = props.description; + this._maxLength = props.maxLength; + this._maxValue = props.maxValue; + this._minLength = props.minLength; + this._minValue = props.minValue; + this._noEcho = props.noEcho; + } + + /** + * The data type for the parameter (DataType). + * + * @default String + */ + public get type(): string { + return this._type; + } + + public set type(type: string) { + this._type = type; + } + + /** + * A value of the appropriate type for the template to use if no value is specified + * when a stack is created. If you define constraints for the parameter, you must specify + * a value that adheres to those constraints. + * + * @default - No default value for parameter. + */ + public get default(): any { + return this._default; + } + + public set default(value: any) { + this._default = value; + } + + /** + * A regular expression that represents the patterns to allow for String types. + * + * @default - No constraints on patterns allowed for parameter. + */ + public get allowedPattern(): string | undefined { + return this._allowedPattern; + } + + public set allowedPattern(pattern: string | undefined) { + this._allowedPattern = pattern; + } + + /** + * An array containing the list of values allowed for the parameter. + * + * @default - No constraints on values allowed for parameter. + */ + public get allowedValues(): string[] | undefined { + return this._allowedValues; + } + + public set allowedValues(values: string[] | undefined) { + this._allowedValues = values; + } + + /** + * A string that explains a constraint when the constraint is violated. + * For example, without a constraint description, a parameter that has an allowed + * pattern of [A-Za-z0-9]+ displays the following error message when the user specifies + * an invalid value: + * + * @default - No description with customized error message when user specifies invalid values. + */ + public get constraintDescription(): string | undefined { + return this._constraintDescription; + } + + public set constraintDescription(desc: string | undefined) { + this._constraintDescription = desc; + } + + /** + * A string of up to 4000 characters that describes the parameter. + * + * @default - No description for the parameter. + */ + public get description(): string | undefined { + return this._description; + } + + public set description(desc: string | undefined) { + this._description = desc; + } + + /** + * An integer value that determines the largest number of characters you want to allow for String types. + * + * @default - None. + */ + public get maxLength(): number | undefined { + return this._maxLength; + } + + public set maxLength(len: number | undefined) { + this._maxLength = len; + } + + /** + * An integer value that determines the smallest number of characters you want to allow for String types. + * + * @default - None. + */ + public get minLength(): number | undefined { + return this._minLength; + } + + public set minLength(len: number | undefined) { + this._minLength = len; + } + + /** + * A numeric value that determines the largest numeric value you want to allow for Number types. + * + * @default - None. + */ + public get maxValue(): number | undefined { + return this._maxValue; + } + + public set maxValue(len: number | undefined) { + this._maxValue = len; + } + /** + * A numeric value that determines the smallest numeric value you want to allow for Number types. + * + * @default - None. + */ + public get minValue(): number | undefined { + return this._minValue; + } + + public set minValue(len: number | undefined) { + this._minValue = len; } /** * Indicates if this parameter is configured with "NoEcho" enabled. */ public get noEcho(): boolean { - return !!this.props.noEcho; + return !!this._noEcho; + } + + public set noEcho(echo: boolean) { + this._noEcho = echo; } /** @@ -165,16 +323,16 @@ export class CfnParameter extends CfnElement { Parameters: { [this.logicalId]: { Type: this.type, - Default: this.props.default, - AllowedPattern: this.props.allowedPattern, - AllowedValues: this.props.allowedValues, - ConstraintDescription: this.props.constraintDescription, - Description: this.props.description, - MaxLength: this.props.maxLength, - MaxValue: this.props.maxValue, - MinLength: this.props.minLength, - MinValue: this.props.minValue, - NoEcho: this.props.noEcho, + Default: this.default, + AllowedPattern: this.allowedPattern, + AllowedValues: this.allowedValues, + ConstraintDescription: this.constraintDescription, + Description: this.description, + MaxLength: this.maxLength, + MaxValue: this.maxValue, + MinLength: this.minLength, + MinValue: this.minValue, + NoEcho: this._noEcho, }, }, };