EC2 Start Instance
Objective
The goal of the tutorial is to start AWS (Elastic Compute Cloud) EC2 instance(s) from FlexDeploy. This automation includes:
Start a virtual machine using one or more instance ids using the AWS CLI
We will walk through each of the FlexDeploy features that will be created/configured to accomplish this goal and start the instance in a very short amount of time.
Checklist
Checklist | Description |
---|---|
AWS Access Key | The access key found on the "Security Credentials" page of the AWS management console. |
AWS Secret Key | The secret key found on the "Security Credentials" page of the AWS management console. |
AWS Default Region | The default region found on the top right corner of the AWS management console. |
instance Id(s) | Provide either comma or space-separated IDs of the instances to start. |
AWS CLI installation | AWS CLI needs to be installed where the plugin operation shall run (e.g. FlexDeploy server) |
AWS CLI in class path | AWS CLI should be added to class path on the FlexDeploy Server. Else the path can also be set under FlexDeploy environment level property. |
Configure cloud account
First, an AWS account needs to be configured under Integrations. FlexDeploy will connect to the AWS account with provided details and starts the instance(s).
Select Integrations from the Menu.
Navigate to the Cloud tab from the left-hand pane.
Create a new Cloud account of the provider type “AWS” with the “+ Create” button.
It should have a AWS Access Key, AWS Secret Key, and AWS Default Region to be configured in it. The AWS Access Key must have relevant access to Start/Stop the instance(s).
Secret Key is a password field and hence needs to be kept hidden. To update the same click on the pencil icon as shown below
Update the Secret Key value under Secret Text. This is to make sure no one else can retrieve the password
After saving the credential, click on Save on the cloud instance. Test connection will not work for the AWS cloud.
Utility Workflow
Navigate to Workflows and create a workflow using the button as highlighted below.
Workflow Properties
From the Properties tab, create a workflow property with Project scope as shown below:
Click + Create
Properties must each have a unique code, give a meaningful code for the new property.
A property display name does not have to be unique and can contain spaces. This is the name that will be displayed on the Project Properties screen
Select the property scope, this defines where the property will be configured. We're using Project scope.
Enter a good description for the property, this will make configuration easier in the future
Save the new property
Workflow Definition
Going back to the Definition tab, here is a sample utility workflow.
The startInstance operation returns three output variables. To capture them and use them for further processing/evaluation, one can create three variables and map them against the output parameters. Return As Output option should be checked in case we want to return them as Workflow output.
First, click the X2 button to open the Variables popup
Next, click the Create button and add three output variables.
Map the variables against the outputs of the Startinstance operation to capture the responses, and also update the plugin input values.
We are mapping the Project Property (AWS_EC2_INSTANCE_ID) against the instance IDs input to dynamically pass the instance ID from the Project property.
Note: You can also hard code the instance IDs directly as a plugin input, or use Target/Environment level property to pass the instance IDs.
Plugin Inputs
Property Name | Type | Description |
---|---|---|
instance Id(s) | Single instance | Provide comma or space separated instance Id(s) to start. (eg. i-073d5fbf3e5766cf4 ) |
Multiple instances space separated | eg. i-073d5fbf3e5766cf4 i-04ed696929f9074e2 | |
Multiple instances comma separated | e.g. i-073d5fbf3e5766cf4,i-04ed696929f9074e2 |
Topology
For detailed steps on how to configure the topology and map the workflows manually, please refer to Configure the Topology
Target Properties
Selecting the DEV environment mapped to the Target Group will display the configurable properties/Endpoint and allows to the configure the Target properties.
Provide the value for AWSEndpoint(optional), AWSCloudAccount, AWSRegion (optional but can be used to override the region defined in the AWS cloud instance), AWSCLIPath(optional,not needed if set in classPath), Number of Iterations (optional, default value is 6), and Interval Duration (optional default value is 30sec) and map the localhost as Endpoint as shown below.
Target Properties Info
Property Name | Mandatory | Values for this Tutorial | Description |
---|---|---|---|
AWS Endpoint | Optional |
| The AWS Endpoint to use. |
AWS Cloud Account | Yes | AWSFlexDev | The AWS Cloud Account Name configured. |
Absolute path of AWS CLI | Optional | /usr/local/bin | The path to the directory where Azure CLI is installed. (Optional) |
AWS Region | Optional |
| The default region found on the top right corner of the AWS Management console. e.g. us-west-2 |
Number of Iterations | Optional (default is 6) | 6 | The number of iterations to perform the status check. |
Interval between status check | Optional (default is 30) | 15 | The interval between EC2 instance status check. |
Create the AWS EC2 Start instance Project
For details steps on how to configure the project and execution, please refer to Create the AWS EC2 Start/Stop Instance Project
Reports
With the successful execution of the Utility workflow, a text (.txt) file is created, stored in the reports tab. Every execution will generate a new report with execution Id appended to the text file in the Reports tab.
Click on the text file generated to see the details. This file captures the details of each instance i.e., instance Id, instance State, instance Status, and System Status. In the workflow, there were two EC2 instance Id’s provided as input. Hence, the report contains the details of both the EC2 instances. Also, user can download the report file generated.
Congratulations! You have successfully completed the EC2 Start instance tutorial.
Now that you have configured FlexDeploy for one EC2 Start instance, it is extremely easy to replicate the same for other EC2 Start instance. Simply use the Copy Project feature and a new project will be created with all of the configuration completed already. You just need to make the necessary configuration changes.
- style