As a cloud administrator, you can leverage the Amazon Web Services (AWS) plug-in to provision plug-in based EC2 instances as you build your infrastructure. You can also use allocation helpers to provide allocation logic for your instances.

You can easily configure your EC2 instances to support your infrastructure needs using the latest AWS properties. For example, if you'd like to automatically recover an instance if a status check fails, you can use the auto_recovery_enabled property in your template during provisioning.

To learn more about plug-ins and allocation in VMware Aria Automation, see Plug-in based designs and deployments in Automation Assembler.

EC2 instance properties

The following properties are required for plug-in based EC2 instance resources.

Property Description
name The name for the instance.
region The region where the instance will be deployed.
account

The AWS cloud account for which your team deploys templates. For more information, see Create an Amazon Web Services cloud account in VMware Aria Automation.

image_id The ID of the AMI to use for the instance.

The following section contains example templates for provisioning EC2 instances.

Provisioning a simple EC2 instance

The following template shows how you might provision an EC2 instance with statically configured values for all its properties.

formatVersion: 1
inputs: {}
resources:
  Idem_AWS_EC2_INSTANCE_1:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: my-instance-1
      region: us-east-1
      account: AWS
      image_id: ami-0aa7d40eeae50c9a9
      availability_zone: us-east-1a
      instance_type: t2.small
      subnet_id: subnet-07d2c529b6336bd0e

Provisioning an EC2 instance with allocation helpers

The following template shows how you might provision an EC2 instance with several allocation helpers.

You can use helpers in a one-to-many configuration, where one helper provides allocation logic, such as zone placement, for several resources. You then further customize the resources according to their full list of properties as defined by the cloud provider and supported by the associated plug-in.

In this example, you use a compute helper, a flavor helper, an image helper, and a network helper.

formatVersion: 1
inputs:
  instance_name:
    type: string
resources:
  Allocations_Compute_1:
    type: Allocations.Compute
    properties:
      constraints:
        - tag: env:dev
  Allocations_Flavor_1:
    type: Allocations.Flavor
    properties:
      flavor: small
  Allocations_Image_1:
    type: Allocations.Image
    properties:
      image: ubuntu
  Allocations_Network_1:
    type: Allocations.Network
    properties:
      networkType: existing
      constraints:
        - tag: alternative-net
  Idem_AWS_EC2_INSTANCE_1:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${input.instance_name}
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      image_id: ${resource.Allocations_Image_1.selectedImageId}
      availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName}
      subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id}

Provisioning an EC2 instance with an AWS volume

The following template shows how you might provision an EC2 instance with an attached volume. In this example, you provision two plug-in based instances and a plug-in based AWS volume. The AWS volume is attached to one of the instances and is encrypted with a classic KMS key.

The AWS volume and the KMS key both reference the same allocation helpers through the use of property bindings. Using property bindings ensures that your resources are provisioned in the correct account and region.

formatVersion: 1
inputs:
  instance_name:
    type: string
  instance2_name:
    type: string
  volume_name:
    type: string
resources:
  Allocations_Compute_1:
    type: Allocations.Compute
    properties:
      constraints:
        - tag: env:dev
  Allocations_Flavor_1:
    type: Allocations.Flavor
    properties:
      flavor: small
  Allocations_Image_1:
    type: Allocations.Image
    properties:
      image: ubuntu
  Allocations_Network_1:
    type: Allocations.Network
    properties:
      networkType: existing
      constraints:
        - tag: alternative-net
  Idem_AWS_EC2_INSTANCE_1:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${input.instance_name}
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      image_id: ${resource.Allocations_Image_1.selectedImageId}
      availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName}
      subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id}
  Idem_AWS_EC2_INSTANCE_2:
    type: Idem.AWS.EC2.INSTANCE
    properties:
      name: ${input.instance2_name}
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      image_id: ${resource.Allocations_Image_1.selectedImageId}
      availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName}
      subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id}
      block_device_mappings:
        - volume_id: ${resource.Idem_AWS_EC2_VOLUME_1.resource_id}
          device_name: /dev/sdb
  Idem_AWS_EC2_VOLUME_1:
    type: Idem.AWS.EC2.VOLUME
    properties:
      name: ${input.volume_name}
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}
      availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id}
      size: 10
      volume_type: io2
      iops: 100
      encrypted: true
      kms_key_id: ${resource.Cloud_Service_AWS_KMS_Key_1.key_id}
  Cloud_Service_AWS_KMS_Key_1:
    type: Cloud.Service.AWS.KMS.Key
    properties:
      region: ${resource.Allocations_Compute_1.selectedRegion.id}
      account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}