CloudFormation: 특정 지역의 키 쌍 목록을 가져오는 방법

CloudFormation: 특정 지역의 키 쌍 목록을 가져오는 방법

EC2 인스턴스를 생성하는 매우 간단한 CF 템플릿이 있습니다. 키 쌍은 매개변수로 지정됩니다. 가능한 키 쌍 목록이 자동으로 채워지도록 하고 싶습니다.

Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone: eu-west-2a
      ImageId: ami-0e80a462ede03e653
      InstanceType: t3.nano
      KeyName: !Ref SSHKey

Parameters:
  SSHKey:
    Type: String
    Description: name of the key pair to ssh into the instance
    AllowedValues:
      # populate automatically

템플릿이 배포되는 지역에서 CloudFormation을 사용하여 키 쌍 목록을 검색하려면 어떻게 해야 합니까?

답변1

Type: String사용하는 대신Type: AWS::EC2::KeyPair::KeyName그러면 목록이 자동으로 채워집니다.

이렇게 해야 합니다:

Parameters:
  SSHKey:
    Type: AWS::EC2::KeyPair::KeyName
    Description: name of the key pair to ssh into the instance

확인해 보세요AWS 관련 매개변수 유형사용할 수 있는 매개변수 유형의 전체 목록을 확인하세요. 일부는 사용 가능한 값(예: SSH 키, VPC ID, 서브넷 ID 등)을 채우고 일부는 그렇지 않습니다(예: AMI 이미지 ID).

도움이 되었기를 바랍니다 :)

관련 정보