.NET Framework CI/CD for Amazon ECS on AWS
Partner Solution Deployment Guide
June 2021
Carlos Santos
Dave May, AWS Quick Start team
Refer to the GitHub repository to view source files, report bugs, submit feature ideas, and post feedback about this Partner Solution. To comment on the documentation, refer to Feedback. |
This Partner Solution was created by Amazon Web Services (AWS). Partner Solutions are automated reference deployments that help people deploy popular technologies on AWS according to AWS best practices. If you’re unfamiliar with AWS Partner Solutions, refer to the AWS Partner Solution General Information Guide.
Overview
This guide covers the information you need to deploy the .NET Framework CI/CD for Amazon ECS Partner Solution in the AWS Cloud.
This Amazon Web Services (AWS) Partner Solution deploys a continuous integration and continuous delivery (CI/CD) pipeline on the Amazon Web Services (AWS) Cloud for .NET applications that run on Amazon Elastic Container Service (Amazon ECS). Your application is updated each time code is changed on your configured GitHub repository branch without interrupting the Amazon ECS service.
AWS CodePipeline creates a pipeline with source, build, and deploy stages. During the source stage, code is retrieved from GitHub and stored on Amazon Simple Storage Service (Amazon S3). In the build stage, AWS CodeBuild and AWS Systems Manager build a new Docker container image of your code on a temporary Amazon Elastic Compute Cloud (Amazon EC2) instance. In the deploy stage, AWS CodeDeploy deploys the updated image to Amazon ECS.
This solution is for developers who want to deploy a continuous integration and continuous delivery (CI/CD) pipeline on the AWS Cloud to update .NET applications on Amazon Elastic Container Service (Amazon ECS).
Costs and licenses
There is no cost to use this Partner Solution, but you will be billed for any AWS services or resources that this Partner Solution deploys. For more information, refer to the AWS Partner Solution General Information Guide.
Architecture
Deploying this Partner Solution with default parameters builds the following .NET Framework CI/CD for Amazon ECS environment in the AWS Cloud.
As shown in Figure 1, this Partner Solution sets up the following:
-
AWS CodePipeline to create a pipeline with source, build, and deploy stages. The pipeline is invoked when a developer commits a code change to the configured GitHub repository branch.
-
An Amazon S3 bucket to store pipeline artifacts.
-
AWS CodeBuild to build the source code into a new Docker container image. AWS CodeBuild connects to AWS Systems Manager, which automates the following build tasks:
-
Retrieves code from Amazon S3.
-
Provisions a temporary Amazon EC2 instance in the default virtual private cloud (VPC).
-
Builds a new Docker container image from the source code.
-
Publishes the new Docker container image to Amazon Elastic Container Registry (Amazon ECR).
-
-
AWS CodeDeploy to deploy the new Docker container image to Amazon ECS.
* The template that deploys this Partner Solution into an existing VPC skips the components marked by asterisks and prompts you for your existing VPC configuration.
Deployment options
This Partner Solution provides the following deployment options:
-
Deploy .NET Framework CI/CD for Amazon ECS with a new ECS cluster. This option provisions the .NET Framework CI/CD for Amazon ECS with a new ECS cluster as the target.
-
Deploy .NET Framework CI/CD for Amazon ECS with an existing ECS cluster. This option provisions the .NET Framework CI/CD for Amazon ECS with an existing ECS cluster as the target.
This Partner Solution provides separate templates for these options.
Predeployment steps
Deployment steps
-
Sign in to your AWS account, and launch this Partner Solution, as described under Deployment options. The AWS CloudFormation console opens with a prepopulated template.
-
Choose the correct AWS Region, and then choose Next.
-
On the Create stack page, keep the default setting for the template URL, and then choose Next.
-
On the Specify stack details page, change the stack name if needed. Review the parameters for the template. Provide values for the parameters that require input. For all other parameters, review the default settings and customize them as necessary. When you finish reviewing and customizing the parameters, choose Next.
Unless you’re customizing the Partner Solution templates or are instructed otherwise in this guide’s Predeployment section, don’t change the default settings for the following parameters: QSS3BucketName
,QSS3BucketRegion
, andQSS3KeyPrefix
. Changing the values of these parameters will modify code references that point to the Amazon Simple Storage Service (Amazon S3) bucket name and key prefix. For more information, refer to the AWS Partner Solutions Contributor’s Guide. -
On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you finish, choose Next.
-
On the Review page, review and confirm the template settings. Under Capabilities, select all of the check boxes to acknowledge that the template creates AWS Identity and Access Management (IAM) resources that might require the ability to automatically expand macros.
-
Choose Create stack. The stack takes about 5 minutes to deploy.
-
Monitor the stack’s status, and when the status is CREATE_COMPLETE, the .NET Framework CI/CD for Amazon ECS deployment is ready.
-
To view the created resources, choose the Outputs tab.
Postdeployment steps
To test your pipeline, do the following:
-
Make a code change to your configured source repository, commit, and push the change.
-
Open the CodePipeline console at https://console.aws.amazon.com/codepipeline/.
-
Choose your pipeline from the list.
-
Watch the pipeline progress through its stages. Your pipeline should complete and your Amazon ECS service runs the Docker image that was created from your code change.
-
Open the Amazon ECS console.
-
Navigate to the Amazon ECS task updated by the pipeline and expand the container details.
-
Open the URL for the application. Confirm that your application sample is deployed.
Troubleshooting
For troubleshooting common Partner Solution issues, refer to the AWS Partner Solution General Information Guide and Troubleshooting CloudFormation.
CI/CD pipeline fails in build stage
Select the details link in the build stage. Use the Build logs tab to view the log output from the stage.
While the error message returned from the SSM document execution is logged, this may not provide enough information to diagnose the problem. If this is the case, to view the SSM output for each step, follow these steps:
-
Look for the log entry that begins with "Running execution". The log entry will look similar to Figure 2.
-
Navigate to the AWS Systems Manager Automation console and select the automation execution matching the ID in the log entry.
-
In the Executed Steps section, select the step that failed.
-
In the Failure Details section, find the exception message.
CI/CD pipeline fails in deploy stage
Typically a pipeline failure in the deploy stage is due to a container instance not meeting all of the task definition’s requirements. To view the details as to why the task could not be updated, follow these steps.
-
Select the details link in the deploy stage. This will navigate you to the Amazon ECS Service Deployments tab.
-
Select the Events tab of the ECS Service to view the log. Use the information in the Message column to diagnose the problem, as shown in Figure 3.
Customer responsibility
After you deploy a Partner Solution, confirm that your resources and services are updated and configured—including any required patches—to meet your security and other needs. For more information, refer to the Shared Responsibility Model.
Feedback
To submit feature ideas and report bugs, use the Issues section of the GitHub repository for this Partner Solution. To submit code, refer to the Partner Solution Contributor’s Guide. To submit feedback on this deployment guide, use the following GitHub links:
Notices
This document is provided for informational purposes only. It represents current AWS product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS products or services, each of which is provided "as is" without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.
The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at https://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "as is" basis, without warranties or conditions of any kind, either expressed or implied. Refer to the License for specific language governing permissions and limitations.