# Copyright 2016-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Description: Creates a VPC and 3 subnets with automatically assigned CIDR ranges. Outputs the calculated ranged. Resources: # Create a new VPC for the example Vpc: Type: AWS::EC2::VPC Properties: CidrBlock: 192.168.0.0/23 # Call the custom resource, specify 3 subnets of different sizes. # The resource will have a property called CidrBlocks with an array of 3 CIDR block definitions CidrFindr: Type: Custom::CidrFindr Properties: ServiceToken: !ImportValue CidrFindr VpcId: !Ref Vpc # Refer to the VPC created above Sizes: [24, 25, 26] # 3 subnets of differing sizes Subnet1: Type: AWS::EC2::Subnet Properties: VpcId: !Ref Vpc CidrBlock: !GetAtt CidrFindr.CidrBlock1 Subnet2: Type: AWS::EC2::Subnet Properties: VpcId: !Ref Vpc CidrBlock: !GetAtt CidrFindr.CidrBlock2 Subnet3: Type: AWS::EC2::Subnet Properties: VpcId: !Ref Vpc CidrBlock: !GetAtt CidrFindr.CidrBlock3 Outputs: Subnet1Cidr: Description: Subnet 1 CIDR Block Value: !GetAtt CidrFindr.CidrBlock1 Subnet2Cidr: Description: Subnet 2 CIDR Block Value: !GetAtt CidrFindr.CidrBlock2 Subnet3Cidr: Description: Subnet 3 CIDR Block Value: !GetAtt CidrFindr.CidrBlock3