Skip to content

Commit 9d802ce

Browse files
committed
Finish readme
1 parent 0529312 commit 9d802ce

File tree

7 files changed

+119
-4
lines changed

7 files changed

+119
-4
lines changed

LeaveWebApp/LeaveWebApp/aws-ecs-tools-defaults.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"task-definition-name" : "LeaveWebApp",
1414
"task-cpu" : "256",
1515
"task-memory" : "512",
16-
"task-definition-task-role" : "",
16+
"task-definition-task-role" : "arn:aws:iam::831210339789:role/ecsTaskExecutionRole",
1717
"task-execution-role" : "ecsTaskExecutionRole",
1818
"container-name" : "LeaveWebApp",
1919
"container-port-mapping" : "80:80",
@@ -23,7 +23,7 @@
2323
"desired-count" : 1,
2424
"deployment-minimum-healthy-percent" : 50,
2525
"deployment-maximum-percent" : 200,
26-
"elb-target-group" : "",
26+
"elb-target-group" : "arn:aws:elasticloadbalancing:us-east-1:831210339789:targetgroup/NewLeaveWebApp/d4422798b18fa9d3",
2727
"elb-container-port" : 80,
2828
"vstoolkit-deployment-mode" : "DeployService"
2929
}

PushtoXRayPol.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Action": [
7+
"xray:PutTraceSegments",
8+
"xray:PutTelemetryRecords"
9+
],
10+
"Resource": [
11+
"*"
12+
]
13+
}
14+
]
15+
}

images/LeaveWebAppHome.png

114 KB
Loading

images/PublishWebApp.png

110 KB
Loading

images/PublishWebApp2.png

97.5 KB
Loading

images/PublishWebApp3.png

82.3 KB
Loading

readme.md

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Create a fully decoupled, microservices architecture based Leave Management appl
4646
https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up-windows.html
4747
* Clone this GitHub repo
4848
* https://github.com/awsimaya/DecoupledArchitecture
49+
* Install Docker for Windows
50+
* Download from here - https://docs.docker.com/docker-for-windows/install/
4951
### Create Workflow services
5052
#### Create Amazon SNS Topic
5153

@@ -113,7 +115,7 @@ We will be creating the following resources as a result of this section
113115
* A Lambda function called **GetLeaveRequests**
114116
* An API Gateway API called **LeaveManagementAPI**
115117

116-
#### Steps
118+
##### Steps
117119

118120
* Open **LeaveManagementAPI.sln** from **LeaveManagementAPI** folder
119121
* 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
142144
* In the publish wizard, enter **LeaveRequestProcessor** in the **Stack Name** textbox
143145
* Enter any name for the S3bucket in the **S3 Bucket** text box
144146
* 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+
![PublishWebApp](/images/PublishWebApp.png)
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+
![PublishWebApp](/images/PublishWebApp2.png)
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+
![LeaveWebAppHome](/images/LeaveWebAppHome.png)
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
245+
![Xray](/images/X-Ray.png)

0 commit comments

Comments
 (0)