LoginSignup
3
0

More than 5 years have passed since last update.

CloudFormation Fn::Cidr の実行例

Posted at

Fn::Cidr関数の実行例がなくて実行イメージがわからなかったので記載

使い方はFn::Cidr - AWS CloudFormationを参照。

サンプルテンプレート

---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Amazon EKS Sample VPC'

Parameters:
  VpcBlock:
    Type: String
    Default: 192.168.0.0/16
    Description: The CIDR range for the VPC. This should be a valid private (RFC 1918) CIDR range.

Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcBlock
      EnableDnsSupport: true
      EnableDnsHostnames: true

Outputs:
  Subnets:
    Description: Output Fn::Cidr
    Value: !Join [ ":", !Cidr [ !Ref VpcBlock, 10, 8 ] ]

結果

リストで取得できるのね。
Screen Shot 2018-08-11 at 15.04.34.png

所感

この関数でハードコードする部分が減りそう。
テンプレートの再利用にも役に立ちそう。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0