Step 1: Create and configure the Auto Scaling group – AWS CodeDeploy

  • Call the create-launch-template command to create
    an Amazon EC2 launch template.

    Before you call this command, you need the ID of an AMI that works for
    this tutorial, represented by the placeholder
    image-id. You also need the name of an Amazon EC2
    instance key pair to enable access to the Amazon EC2 instance, represented by the
    placeholder key-name.

    To get the ID of an AMI that works with this tutorial:

    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    2. In the navigation pane, under Instances,
      choose Instances, and then choose
      Launch Instance.

    3. On the Quick Start tab of the
      Choose an Amazon Machine Image page, note
      the ID of the AMI next to Amazon Linux 2 AMI,
      Red Hat Enterprise Linux 7.1, Ubuntu Server 14.04
      LTS
      , or Microsoft Windows Server 2012
      R2
      .

      Note

      If you have a custom version of an AMI that is compatible with
      CodeDeploy, choose it here instead of browsing through the
      Quick Start tab. For information about
      using a custom AMI with CodeDeploy and Amazon EC2 Auto Scaling, see Using a custom AMI with CodeDeploy
      and Amazon EC2 Auto Scaling.

    For the Amazon EC2 instance key pair, use the name of your Amazon EC2 instance key
    pair.

    Call the create-launch-template command.

    On local Linux, macOS, or Unix machines:

    aws ec2 create-launch-template \ --launch-template-name CodeDeployDemo-AS-Launch-Template \ --launch-template-data file://config.json

    The contents of the config.json file:

    {

    "InstanceType":"t1.micro", "ImageId":"image-id", "IamInstanceProfile":

    {

    "Name":"CodeDeployDemo-EC2-Instance-Profile" }, "KeyName":"key-name" }

    On local Windows machines:

    aws ec2 create-launch-template --launch-template-name CodeDeployDemo-AS-Launch-Template --launch-template-data file://config.json

    The contents of the config.json file:

    {

    "InstanceType":"t1.micro", "ImageId":"image-id", "IamInstanceProfile":

    {

    "Name":"CodeDeployDemo-EC2-Instance-Profile" }, "KeyName":"key-name" }

    These commands, along with the config.json file, create an Amazon EC2 launch template named CodeDeployDemo-AS-Launch-Template for your Auto Scaling
    group that will be created in a following step based on the t1.micro Amazon EC2 instance type. Based on your input for ImageId,
    IamInstanceProfile, and KeyName, the launch template also specifies the AMI ID, the name of the instance profile
    associated with the IAM role to pass to instances at launch, and the Amazon EC2 key pair to use when connecting to instances.

  • Alternate Text Gọi ngay