Custom::FindAMI

The Custom::FindAMI resource finds an AMI by owner, name and architecture. The result can thenbe used with Ref

Syntax

JSON

{
  "Type" : "Custom::FindAMI",
  "Properties" : {
    "ServiceToken" : {"Fn::ImportValue": "cfm-reslib"},
    "Owner" : string,
    "Name" : string,
    "Architecture" : string
  }
}

YAML

Type: Custom::FindAMI
Properties :
  ServiceToken : !ImportValue cfm-reslib
  Owner : string
  Name : string
  Architecture : string

Properties

Owner

Image owner (e.g. "679593333241" for CentOS)

Required: No

Type: string

Update requires: Replacement

Name

Image name (e.g. "CentOS Linux 7 x86_64 HVM EBS *")

Required: No

Type: string

Update requires: Replacement

Architecture

Image architecture (e.g. "x86_64")

Required: No

Type: string

Update requires: Replacement

Examples

Create EC2 Instance With Latest Ubuntu

The following example searches for the latest version of Ubuntu 16.04 AMI and creates a newEC2 instance with this image.

JSON

{
  "UbuntuAMI": {
    "Type": "Custom::FindAMI",
    "Properties": {
      "ServiceToken": {
        "Fn::ImportValue": "cfm-reslib"
      },
      "Owner": "099720109477",
      "Name": "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04*",
      "Architecture": "x86_64"
    }
  },
  "UbuntuInstance": {
    "Type": "AWS::EC2::Instance",
    "Properties": {
      "InstanceType": "t2.micro",
      "ImageId": {
        "Ref": "UbuntuAMI"
      }
    }
  }
}

YAML

UbuntuAMI:
  Properties:
    Architecture: x86_64
    Name: ubuntu/images/hvm-ssd/ubuntu-xenial-16.04*
    Owner: "099720109477"
    ServiceToken:
      Fn::ImportValue: cfm-reslib
  Type: Custom::FindAMI
UbuntuInstance:
  Properties:
    ImageId:
      Ref: UbuntuAMI
    InstanceType: t2.micro
  Type: AWS::EC2::Instance