How to disable CloudFormation Input parameter for user

0

I am trying to use the following input parameter in my template:

AmiID:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Description: Only the following image is supported currently.
    Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
    ConstraintDescription: Must be a supported AMI ID.

And, i don't want the user to mess with this input parameter. Is it possible to restrict user from editing this particular field in stack creation process?

질문됨 9달 전471회 조회
3개 답변
2
수락된 답변

I assume you are using this for EC2 resource, e.g.

Parameters:
  LatestAmiId:
    Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'

Resources:
 Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: !Ref LatestAmiId

An option is not to specify it as a parameter. Instead use resolve:ssm function as per below

Resources:
 Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}"
AWS
전문가
Mike_L
답변함 9달 전
1

Hi

You can probably use the AllowedValues in CloudFormation to create a list of allowed values. Only the values in this list can be used, so if you have a list with only one value the user must use that.

AmiID:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Description: Only the following image is supported currently.
    Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
    AllowedValues:
        -  /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
    ConstraintDescription: Must be a supported AMI ID.
profile picture
전문가
답변함 9달 전
profile picture
전문가
검토됨 9달 전
0

Not sure if possible but one approach could be to look into the Cloudformation Conditions and apply to the input: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html

profile picture
전문가
답변함 9달 전

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

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

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

관련 콘텐츠