AWS::EC2::AvailabilityZone::Name Parameter Validation...

0

I have an AWS::EC2::AvailabilityZone::Name as a parameter for my CloudFormation template like this:

AvailabilityZone:
Type: AWS::EC2::AvailabilityZone::Name
Description: New subnets will be created for this zone.
ConstraintDescription: "A valid availability zone must be selected."

It populates nicely with the list of Availability Zones for the region where the CloudFormation template is coming up. However, CloudFormation does not validate that an Availability Zone was selected (i.e. it can be left blank). After the "Create Stack" button is pushed the stack creation process will fail.

I would like to be able to validate the parameter and make sure that it is not empty before the stack fails. I tried specifying a "MinLength" property of 9. I uploaded the template and it would not let me enter an empty Availability Zone (i.e. it seemed to work). However, in our build process we call cfn-lint to validate the template and it gives the following error:

E2001 Parameter AvailabilityZone has property MinLength which is only valid for \['String']

Can anyone tell me what is the correct way to validate an AWS::EC2::AvailabilityZone::Name field to be non empty at least, and preferably an item in the list provided by the GUI?

Thanks in advance,

Edited by: hdsiii on May 15, 2020 11:24 AM

Edited by: hdsiii on May 15, 2020 11:26 AM

Edited by: hdsiii on May 18, 2020 4:24 PM

hdsiii
질문됨 4년 전1011회 조회
1개 답변
0

AWS tech support sent me an answer. Although MinLength is not supported on AvailabilityZone::Name, AllowedPattern is. Here is a pattern that ensures the AvailabilityZone::Name is at least 1 character long. Since this is a popup field it ensures that the popup is populated and not left blank.

===================================================
AvailabilityZone:
Type: AWS::EC2::AvailabilityZone::Name
Description: EC2 AvailabilityZone
AllowedPattern: ".+" # -> to have a non blank value

FYI: Using a DefaultValue is not really an option since I don't know what Region the script is being run in.

hdsiii
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠