You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Download from here - https://docs.docker.com/docker-for-windows/install/
49
51
### Create Workflow services
50
52
#### Create Amazon SNS Topic
51
53
@@ -113,7 +115,7 @@ We will be creating the following resources as a result of this section
113
115
* A Lambda function called **GetLeaveRequests**
114
116
* An API Gateway API called **LeaveManagementAPI**
115
117
116
-
#### Steps
118
+
#####Steps
117
119
118
120
* Open **LeaveManagementAPI.sln** from **LeaveManagementAPI** folder
119
121
* Right click on **LeaveManagementAPI** project and click **Publish to AWS Lambda...**
@@ -142,4 +144,102 @@ We will be creating the following resources as a result of this section
142
144
* In the publish wizard, enter **LeaveRequestProcessor** in the **Stack Name** textbox
143
145
* Enter any name for the S3bucket in the **S3 Bucket** text box
144
146
* Click **Publish**
145
-
* Visual Studio will open a new window to show the progress of the deployment and will show **CREATE_COMPLETE** once successfully deployed
147
+
* Visual Studio will open a new window to show the progress of the deployment and will show **CREATE_COMPLETE** once successfully deployed
148
+
149
+
### Create Web front end
150
+
151
+
> In this section we will create the web front end that will help users create and manage leave approval requests
152
+
153
+
#### Create a new IAM role for ECS task execution
154
+
> In this section, we will create a new IAM role for the ECS Service you will create to assume
155
+
* Open AWS console and navigate to **IAM** -> **ROLES**
156
+
* Click **Create role**
157
+
* In the next screen, select **AWS service** for **Select type opf trusted identity**
158
+
* Select **Elastic Container Service** under **Choose the service that will use this role**
159
+
* Select **Elastic Container Service Task** under **Select your use case**. Click **Next: Permissions**
160
+
* In the next screen, select **AmazonECSTaskExecutionRolePolicy** policy, click **Attach policy** and click **Next: Tags**
161
+
* Click **Next** in the next page
162
+
* Enter **ecsTaskExecutionRole** as name in the next page. Click **Create role**
163
+
* Go back to **ecsTaskExecutionRole**, click **Add Inline policy** and go to **JSON** tab
164
+
* Copy and paste the following JSON into the textarea
165
+
```json
166
+
{
167
+
"Version": "2012-10-17",
168
+
"Statement": [
169
+
{
170
+
"Effect": "Allow",
171
+
"Action": [
172
+
"xray:PutTraceSegments",
173
+
"xray:PutTelemetryRecords"
174
+
],
175
+
"Resource": [
176
+
"*"
177
+
]
178
+
}
179
+
]
180
+
}
181
+
```
182
+
* Click **Review policy**
183
+
* Name the policy as **PushtoXRayPol** and click **Create policy**
184
+
185
+
#### Publish web app to Amazon ECS
186
+
> In this section, we will publish the Web application to Amazon ECS
187
+
* Open **LeaveWebApp.sln** file from the **LeaveWebApp** folder
188
+
* In **HomeController.cs**, replace **<API_GATEWAY_URL>** with the API Gateway URL you saved in step **Create LeaveManagementAPIs**
189
+
* Right click on **LeaveWebApp** project and click **Publish Container to AWS...**
190
+
* In the wizard, enter **leavewebapp** in **Docker Repository** field
191
+
* Select **Service on ECS Cluster** option (as shown below) and click **Next**
192
+

193
+
* In the next window, select **Create an empty cluster** and enter **LeaveWebApp** in the textbox next to the dropdown. Click **Next**
194
+
* In the next window, select **Create New** for **Service** and enter **LeaveWebApp** in the textbox next to dropdown. Click **Next**
195
+
* In the next window, check **Configure Application Load Balancer** check box, select **Create New** for **Load Balancer:** dropdown and enter **LeaveWebApp** in the textbox next to it.Click **Next**
196
+

197
+
* In the next window, select **Create New** for **Task Definition** dropdown and enter **LeaveWebApp** in the textbox next to it.
198
+
* Select **Create New** for **Container** dropdown and enther **LeaveWebApp** in the textbox next to it.
199
+
* Select **Existing role: ecsTaskExecutionRole** for **Task Role:** dropdown
200
+
* Select **ecsTaskExecutionRole** for **Task Execution Role** dropdown
201
+
* Click **Publish**
202
+
* Visual Studio will now start publishing the application environment
203
+
* You just published the Web application to Amazon ECS
204
+
* Once complete, you will be able to see a new ECS service called **LeaveWebApp** on the AWS console
205
+
206
+
#### Configure XRay for the ECS Service
207
+
> In this section, we will create a X-Ray daemon container which will run as a side-car container along with the LeaveWebApp container to process and send X-Ray data to the X-Ray service on AWS.
208
+
209
+
> More about this topic here - https://docs.aws.amazon.com/xray/latest/devguide/xray-daemon-ecs.html
210
+
211
+
* Open PowerShell and execute the following commands. The first command pulls the **aws-xray-daemon** container image from docker hub. The second command tags the image as **xraydaemon**
212
+
```docker
213
+
docker pull amazon/aws-xray-daemon
214
+
docker tag amazon/aws-xray-daemon:latest xraydaemon:latest
215
+
```
216
+
* Login to AWS console and navigate to **Amazon ECS**. Click **Repositories** on the left navigation section
217
+
* Click **Create repository** and name it **xraydaemon**
218
+
* Click **Create repository**
219
+
* Click on **View push commands** on the top right of the screen
220
+
* Choose Windows or macOS/Linux tab and execute the command from Step 1. The command will return a very long URL. Copy and paste the URL into the command line and press enter.
221
+
* Skip the step 2 command, because we already have the container image downloaded from docker hub earlier. Execute commands from Step 3 and Step 4.
222
+
* Once complete, go to the **xraydaemon** repository on the AWS ECR home page and ensure the new image has been published successfully
223
+
* Navigate to **Task Definitions** on **Amazon ECS** home page and click **LeaveWebApp**
224
+
* Select the latest version and click **Create new revision**
225
+
* Under **Container Definitions** click **Add container**
226
+
* Name the container **xray-daemon**
227
+
* Copy and paste the container image URI from **xraydaemon** ECR repo into the **Image** textbox
228
+
* Click **Add** button at the bottom
229
+
* Select the newly created version of the Task Definition
230
+
* Select **Actions** -> **Update Service**
231
+
* Select **LeaveWebApp** in the **Cluster** dropdown
232
+
* Check **Force new deployment** checkbox
233
+
* Click **Next step** in the next few screens until you get to **Review** screen. Click **Update Service**
234
+
* You just finished deploying the Leave Web App to Amazon ECS
235
+
236
+
### Test drive the application
237
+
* Copy and paste the DNS name of the **LeaveWebApp** ALB from the EC2 home page on AWS console into a browser and press enter
238
+
* You should be able to see the application as shown below
239
+

240
+
* You can Submit a Leave Request and also Approve a Leave Request using this application by clicking on the appropriate links.
241
+
* Once you submit a Leave Request, you will see an email arrive in your email inbox that you configured earlier
242
+
* Also another email will land in your email inbox once you approve a request as well
243
+
* After you play around with the application for a while, you can navigate to X-Ray home page on AWS console and click **Service map**
244
+
* You should be able to see the service map as shown below
0 commit comments