If you have already declared your VPC as another resource in the same template, you can use Fn::GetAttits CIDR to reference it, like this (assuming MyVPC is the logical name you gave this VPC resource):
{
"OutboundRule": {
"Type": "AWS::EC2::SecurityGroupEgress",
"Properties":{
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp" : { "Fn::GetAtt" : [ "MyVPC", "CidrBlock" ] }
}
}
, Fn::GetAtt, , , , . .
VPC , CIDR CloudFormation { "Ref": "<parmeterName>" } Fn::GetAtt.
Update:
19 2016 ., .
( YAML JSON, ):
1:
...
Outputs:
VpcCidrBlock:
Description: My VPC CIDR block.
Value:
Fn::GetAtt:
- MyVpc
- CidrBlock
Export:
Name: MyVpcCidrBlock
2:
...
Resources:
Type: "AWS::EC2::SecurityGroupEgress"
Properties:
CidrIp:
Fn::ImportValue: MyVpcCidrBlock
FromPort: 80
IpProtocol: tcp
ToPort: 80
: 1 , 2.