Step 3

Step 3 - Create an S3 Bucket using aws:executeAwsApi

In Step 2, we created an Automation document that leverages the automation action aws:executeScript to launch an EC2 instance and check for the instance status to be returned as ok. In this step we will be adding to the Automation document in order to create an S3 bucket which will be used to store execution logs created in Step 4.

Tip: If you copy and paste values from this walkthrough into Document Builder, such as parameter names, make sure to delete any leading or trailing spaces added to the text value you enter.

Update the Custom Automation Document

  • Open the AWS Systems Manager console at

  • In the navigation pane, choose Documents.

  • On the Documents page, select the Owned by me tab and then choose the document you created in Step 1 - Launch an EC2 Instance using aws:runInstances, such as LaunchEC2Instance.

  • Select Actions and then Create new version.

  • For Assume role, enter {{ assumeRole }}. This allows us to pass in the Automation service role using the parameter assumeRole which will be created in subsequent steps.

  • For Outputs, replace the existing value with the following.

["launchEc2Instance.OutputPayload", "waitForInstanceStatusOk.OutputPayload"]
  • Expand Input parameters and do the following.

    • Important: Do not modify the previously created parameters: imageId, tagValue, instanceType, instanceIAMrole, and assumeRole.
  • Choose Add a parameter to create the sixth parameter, s3BucketName, and enter the following.

    • For Parameter name, enter s3BucketName.
    • For Type, choose String.
    • For Required, choose No.
    • For Default value, enter nycloft-builders-{{ automation:EXECUTION_ID }}. This creates a name that is unique by using the execution ID of the initiated Automation workflow.
    • For Description, enter the following.
(Required) The name of the S3 bucket to create. The name of the bucket must be globally unique.
  • Below the second step, choose Add step to add a third step to the Automation document. The third step creates a new S3 bucket.

  • In the Step 3 section, do the following.

    • For Step name, enter createS3Bucket.
    • For Action type, choose Call and run AWS API actions (aws:executeAwsApi).
    • For Description, enter a description for the automation step, such as the following.
**About This Step**

The S3 API action CreateBucket is called to create a new S3 bucket.
  • For Service, enter s3.
  • For API, enter CreateBucket.
  • Expand Additional inputs.
  • For Input name, enter Bucket. For Input value, enter '{{ s3BucketName }}'.

  • Select Set new version as default.

  • Choose Create new version to save the document.