> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Plugin - Execute Command/Script

> Objective The goal of this tutorial is to execute a shell script on an AWS instance through FlexDeploy using the AWS Plugin. For this tutorial, we wil

## Objective

The goal of this tutorial is to execute a shell script on an AWS instance through FlexDeploy using the AWS Plugin. For this tutorial, we will be setting up an automated execution of the shell script which is present in a Git repository. The steps include:

* Copying the shell script from a Git repository

* Executing the shell script

We will walk through each of the FlexDeploy features that will be created/configured to accomplish this goal and execute the shell script.

## Checklist

<table><colgroup><col /><col /></colgroup><tbody><tr><th>**Checklist**</th><th>**Description**</th></tr><tr><td>AWS Access Key</td><td>AWS Access Key ID of [IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html)</td></tr><tr><td>AWS Secret Key</td><td>Password for the Access Key</td></tr><tr><td>AWS CLI installation</td><td>AWS CLI needs to be installed on the Target m/c where the plugin operation shall run</td></tr><tr><td>AWS CLI in class path</td><td>AWS CLI should be added to the classpath in target m/c. Else the path can also be set under FlexDeploy environment level property</td></tr><tr><td>AWS PowerShell</td><td>AWS PowerShell needs to be installed on Windows OS and path should be added to the classpath in target m/c.Please refer to [[https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up-windows.html](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up-windows.html)](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up-windows.html)</td></tr></tbody></table>

### Configure cloud account

First, AWS account needs to be configured under Topology. FlexDeploy will connect to the AWS cloud and execute the script

1. Navigate to the **Integrations** from the left-hand pane

2. Navigate to the **Cloud** tab under Topology

3. Navigate Create a new Cloud account of provider type “**AWS**” with the “**+**” button.

It should have a AWS Access Key and AWS Secret Key.

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929621.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=141ace9c08cd72e7de8f467f0eaa17cf)

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929606.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=d1ddba2a6607d40a79a68e7a13b3e34c)

1. AWS Access Key is a password field and hence needs to be kept hidden. To update the same click on the **pencil** icon as shown below

2. next update the AWS Access Key value under Secret Text. This is to make sure no one else can retrieve the password

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929627.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=75ffbbce6a24c6ef3d431b87652e6090)

## Git Repository Structure

The Git repository should contain shell script to execute.

The Sample Git repository structure is given below:

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929603.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=46544892c5ab48ebc44452d02e8887cb)

## Build Workflow

Navigate to **Workflows** and create a workflow using the :Create\_Button: button as highlighted below.

![image-20240329-160109.png](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929624.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=a53fe9098de34c97a19c867dd57436b1)

Below given is a sample build workflow to copy and execute the script.

![image-20240329-160259.png](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929633.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=bd9f890d32faa2493eff7242500dd8e1)

**Step-i: Clone Git Repository**

This step will clone the Git repository codebase into the project execution working directory. The Git URL will be retrieved from [Source Control](https://flexagon.atlassian.net/wiki/spaces/FD10/pages/11845812125/Push+Docker+Image+to+AWS+Private+Container+Registry+ECR#%5BinlineExtension%5DSource-Control) configured under Project Configuration.

![image-20240329-160337.png](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929630.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=0fbe64bd7d5df67bc06122c0b6c7f4c2)

**Step-ii: Copy the script file**

The below step will copy the script file to the artifacts directory.

![image-20240329-160434.png](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929639.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=2b6230b71030492abb07727c0162d5ae)

**Step-iii : execute the script file**

Code Snippet field is mandatory, we can select the type of CLI from the drop-down. Available options are shell, PowerShell, and WindowsShell. The default CLI type is shell.

![image-20240329-160604.png](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929636.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=960d97474a2217a4dd093e6abb213a81)

## Project Configuration

Navigate to the Project tab and create a Project with a logical name(AWS-Command in this case)

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929618.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=d486fcb7c837eb5364d644b1d172200b)

Configure the Build workflow that has been created in previous steps as shown below.

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929612.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=8764a239ec6ab6f62a2ece876fdf99d1)

### Source Control

Configure the Source SCM repository under Source Control as shown below.

1. To configure Project specific Source Control one first need to navigate to the Project **Configuration** tab.

2. Next, expand the **SOURCE CONTROL** option from the left-hand pane.

3. Select the appropriate **Source Control Type**

4. Configure **Source Repository**. For detailed steps of Source Control configuration please refer to [Configure Source Control in FlexDeploy](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-tutorials/azure-plugin-tutorials/configure-source-control-in-flexdeploy.md)

### Project Properties

To configure Project specific settings one can navigate to Configuration Properties as shown below.

![Image](https://mintcdn.com/flexagon-llc-ce77a95c/NkeZh5D-Nf8j_WaD/images/fd111/12590929615.png?fit=max\&auto=format\&n=NkeZh5D-Nf8j_WaD\&q=85\&s=f5ee5f1bc52c6e98ef19bc7d6ea4bc53)

1. To configure Project specific settings one can navigate to the Project **Configuration** tab as shown above.

2. Next, select the **PROPERTIES** option from the left-hand pane.

3. Select the target AWS Cloud Account.

## Target Properties

#### Topology

Navigate to the **Topology** from the Menu. The Page with the [Target Groups](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-tutorials/java-application-for-tomcat.md), [Environments](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-tutorials/java-application-for-tomcat.md) and [Endpoints](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-tutorials/java-application-for-tomcat.md) sections will be displayed. Choose a Target Group on the left. You will see a list of Environments on the right with colored circles representing each [Target](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-users-guide/topology/target-groups.md). 

<table><colgroup><col /><col /><col /></colgroup><tbody><tr><td>**Properties**</td><td>**Mandatory field**</td><td>**Description**</td></tr><tr><td>AWS ACCOUNT</td><td>Optional</td><td>AWS cloud account name</td></tr><tr><td>AWS CLI</td><td>Optional</td><td>Directory Where AWS CLI is installed</td></tr><tr><td>GIT Path</td><td>Optional</td><td>Path to the Git executable. Required only if git is not on PATH.</td></tr></tbody></table>

## Build Execution

For detailed steps on how to initiate Build please refer to [Build execution through FlexDeploy for Azure Plugin](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-tutorials/azure-plugin-tutorials/build-execution-through-flexdeploy-for-azure-plugin.md)

Congratulations! You have successfully completed the tutorial.

Now that you have configured FlexDeploy to execute the script, it is extremely easy to replicate the same for other cloud provider as well. 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.
