forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_cidr.yaml
106 lines (106 loc) · 2.58 KB
/
functions_cidr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
AWSTemplateFormatVersion: 2010-09-09
Parameters:
cidrBlock:
Type: String
count:
Type: String
count1:
Type: Number
MinValue: 0
MaxValue: 3000
maskSizeForIPv4:
Type: String
maskSizeForIPv6:
Type: String
maskSizeForIPv41:
Type: Number
MinValue: 0
MaxValue: 750
Conditions:
IsProd: !Equals [!Ref AWS::AccountId, '123456789012']
Resources:
Subnet1:
Type: AWS::EC2::Subnet
Properties:
AssignIpv6AddressOnCreation: true
VpcId: !Ref VPC
#Test Ipv4 CidrBlock
CidrBlock: !Select [0, !Cidr [!Ref cidrBlock, "a", "/32"]]
#Test Ipv6 CidrBlock
Ipv6CidrBlock:
!Select [
0,
!Cidr [
!Select [0, !GetAtt VPC.Ipv6CidrBlocks],
!Ref count,
!Ref maskSizeForIPv6,
],
]
DependsOn: Ipv6VPCCidrBlock
Subnet2:
Type: AWS::EC2::Subnet
Properties:
AssignIpv6AddressOnCreation: true
VpcId: !Ref VPC
#Test Ipv4 CidrBlock
CidrBlock:
!Select [1, !Cidr [!Ref cidrBlock, !Ref count1, !Ref maskSizeForIPv41]]
#Test Ipv6 CidrBlock
Ipv6CidrBlock:
!Select [
1,
!Cidr [
!FindInMap [0, !GetAtt VPC.Ipv6CidrBlocks],
!Ref count,
!Ref maskSizeForIPv6,
],
]
DependsOn: Ipv6VPCCidrBlock
Subnet3:
Type: AWS::EC2::Subnet
Properties:
AssignIpv6AddressOnCreation: true
VpcId: !Ref VPC
#Test Ipv4 CidrBlock
CidrBlock:
!Select [0, !Cidr [!Ref cidrBlock, !Ref count, !Ref maskSizeForIPv4]]
#Test Ipv6 CidrBlock
Ipv6CidrBlock:
!Select [
0,
!Cidr [
!Select [0, !GetAtt VPC.Ipv6CidrBlocks],
!Ref count,
!Ref maskSizeForIPv6,
],
]
DependsOn: Ipv6VPCCidrBlock
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref cidrBlock
Ipv6VPCCidrBlock:
Type: AWS::EC2::VPCCidrBlock
Properties:
AmazonProvidedIpv6CidrBlock: true
VpcId: !Ref VPC
SubnetWithConditions:
Type: AWS::EC2::Subnet
Properties:
# /28 block #1 (VPC Allocation), inside /26 block #3, inside /24 block #3 (prod) or block #15 (non-prod)
CidrBlock:
Fn::Select:
- 1
- Fn::Cidr:
- Fn::Select:
- 3
- Fn::Cidr:
- Fn::If:
- IsProd
- "a"
- "b"
- 4
- 6
- 2
- 4
VpcId: "vpc-123456"