Cloudformation AWS:使用参数将 IP 地址分配给 CustomerGateway
Cloudformation AWS: Assign an ip address to a CustomerGateway using parameters
我正在设计一个cloudformation模板,但我需要将源IP定义为一个参数
我试图将参数定义为字符串,但它产生了以下错误:
Value (${MyCustomerGateway}) for parameter ipAddress is invalid. Invalid Format. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 4de02112-fb1f-47a1-931c-97727568df99)
这是模板的片段:
Parameters:
MyCustomerGateway:
Description: IpAddress.
Default: 0.0.0.0
Type: String
Resources:
CustomerGateway_1:
Type: 'AWS::EC2::CustomerGateway'
Properties:
Type: ipsec.1
BgpAsn: 3352
IpAddress: ${MyCustomerGateway}
Tags:
- Key: Name
Value: CustomerGateway_1
IP翻译有什么特殊资料吗?
我不确定哪个是正确的方法
将IpAddress: ${MyCustomerGateway}
更改为IpAddress: !Ref myCustomerGateway
关于 Ref 的更多信息:
The intrinsic function Ref returns the value of the specified
parameter or resource.
> When you specify a parameter's logical name, it returns the value of
the parameter.
When you specify a resource's logical name, it returns a value that
you can typically use to refer to that resource, such as a physical
ID.
奖金:
如果您想验证参数输入,可以使用 AllowedPattern
属性.
用法:
PrimaryIPAddress:
Type: String
Description: This must be a valid IP address.
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})
ConstraintDescription: must be a valid IP address of the form x.x.x.x.
输入无效 IP 时出错:
我正在设计一个cloudformation模板,但我需要将源IP定义为一个参数
我试图将参数定义为字符串,但它产生了以下错误:
Value (${MyCustomerGateway}) for parameter ipAddress is invalid. Invalid Format. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 4de02112-fb1f-47a1-931c-97727568df99)
这是模板的片段:
Parameters:
MyCustomerGateway:
Description: IpAddress.
Default: 0.0.0.0
Type: String
Resources:
CustomerGateway_1:
Type: 'AWS::EC2::CustomerGateway'
Properties:
Type: ipsec.1
BgpAsn: 3352
IpAddress: ${MyCustomerGateway}
Tags:
- Key: Name
Value: CustomerGateway_1
IP翻译有什么特殊资料吗?
我不确定哪个是正确的方法
将IpAddress: ${MyCustomerGateway}
更改为IpAddress: !Ref myCustomerGateway
关于 Ref 的更多信息:
The intrinsic function Ref returns the value of the specified parameter or resource.
> When you specify a parameter's logical name, it returns the value of the parameter.
When you specify a resource's logical name, it returns a value that you can typically use to refer to that resource, such as a physical ID.
奖金:
如果您想验证参数输入,可以使用 AllowedPattern
属性.
用法:
PrimaryIPAddress:
Type: String
Description: This must be a valid IP address.
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})
ConstraintDescription: must be a valid IP address of the form x.x.x.x.
输入无效 IP 时出错: