Skip to content

cdk.Output should validate that it is non-empty #2012

@mahe-work

Description

@mahe-work

When trying to create a VpcNetwork without VpnGateway, VpcNetworks import props cannot be exported.

cdk deploy output:

cdk  deploy 
vpc-stack: deploying...
vpc-stack: creating CloudFormation changeset...

 ❌  vpc-stack failed: ValidationError: Template format error: Every Outputs member must contain a Value object
Template format error: Every Outputs member must contain a Value object

vpc.ts:

import cdk = require("@aws-cdk/cdk");
import ec2 = require("@aws-cdk/aws-ec2");

export interface VPCStackProps extends cdk.StackProps {
    cidr: string,
}

export class VPCStack extends cdk.Stack {
    public readonly exports: ec2.VpcNetworkImportProps;

    constructor(scope: cdk.App, id: string, props: VPCStackProps) {
        super(scope, id)
        const vpc = new ec2.VpcNetwork(this, "vpc", {
            cidr: props.cidr,
            subnetConfiguration: [
                {
                    cidrMask: 26,
                    name: "Public",
                    subnetType: ec2.SubnetType.Public
                },
                {
                    cidrMask: 26,
                    name: "Private",
                    subnetType: ec2.SubnetType.Private
                },
                {
                    cidrMask: 27,
                    name: "DB",
                    subnetType: ec2.SubnetType.Isolated
                },
            ],
            vpnGateway: false
        })

        this.exports = vpc.export();
    }
}

cfn template Outputs section from cdk synth:

Outputs:
  vpcPublicSubnetIDs7CDCF73A:
    Value:
      Fn::Join:
        - ","
        - - Ref: vpcPublicSubnet1Subnet2E65531E
          - Ref: vpcPublicSubnet2Subnet009B674F
          - Ref: vpcPublicSubnet3Subnet11B92D7C
    Export:
      Name: vpc-stack:vpcPublicSubnetIDs7CDCF73A
  vpcPrivateSubnetIDs121CC6B5:
    Value:
      Fn::Join:
        - ","
        - - Ref: vpcPrivateSubnet1Subnet934893E8
          - Ref: vpcPrivateSubnet2Subnet7031C2BA
          - Ref: vpcPrivateSubnet3Subnet985AC459
    Export:
      Name: vpc-stack:vpcPrivateSubnetIDs121CC6B5
  vpcIsolatedSubnetIDs67369DC2:
    Value:
      Fn::Join:
        - ","
        - - Ref: vpcDBSubnet1SubnetA8C3A9ED
          - Ref: vpcDBSubnet2SubnetDB39CD7E
          - Ref: vpcDBSubnet3Subnet54DAF0DD
    Export:
      Name: vpc-stack:vpcIsolatedSubnetIDs67369DC2
  vpcVpcIdE284377C:
    Value:
      Ref: vpcA2121C38
    Export:
      Name: vpc-stack:vpcVpcIdE284377C
  vpcVpnGatewayIdDCE6028A:
    Export:
      Name: vpc-stack:vpcVpnGatewayIdDCE6028A

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalitybugThis issue is a bug.effort/smallSmall work item – less than a day of effort

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions