app2container generate app-deployment command - AWS App2Container

app2container generate app-deployment command

When you run this command, it generates the artifacts needed to deploy your application container in AWS. App2Container pre-fills key values in the artifacts based on your profile, the application analysis, your App2Container workflow, and best practices.

Note

For Windows applications, App2Container chooses the base image for your application container and Amazon ECS cluster, based on the worker machine or application server OS where you run the containerization command. Windows application containers running on Amazon EKS use Windows Server Core 2019 for the base image.

You have three options for deployment to your target container management environment, all of which use Amazon ECR as the container registry (Amazon ECS, Amazon EKS, or App Runner):

  • You can use the --deploy option to deploy directly to your target environment. When your initial deployment uses this option, you can refresh your image by running the command with the deploy option again.

  • You can review and customize deployment artifacts, and then deploy using the AWS CLI or AWS console.

This command accesses AWS resources to generate and deploy artifacts to your target environment. The IAM user with administrator access that you created during security setup is required to run the command with the --deploy option. See Identity and access management in App2Container for more information about setting up IAM users for App2Container.

The command uses the deployment.json file that is generated by the containerize command. You can edit the deployment.json file to specify parameters for your deployment, such as:

  • An image repository name for Amazon ECR

  • Task definition parameters for Amazon ECS

  • The Kubernetes app name

  • The App Runner service name

See Configuring container deployment for more information about configuring the deployment.json file.

Note

If the command fails, an error message is displayed in the console, followed by additional messaging to help you troubleshoot.

When you ran the init command, if you chose to automatically upload logs to App2Container support if an error occurs, App2Container notifies you of the success of the automatic upload of your application support bundle.

Otherwise, App2Container messaging directs you to upload application artifacts by running the upload-support-bundle command for additional support.

Syntax

app2container generate app-deployment --application-id id [--deploy] [--profile admin-profile] [--help]

Parameters and options

Parameters
--application-id id

The application ID (required). After you run the inventory command, you can find the application ID in the inventory.json file in one of the following locations:

  • Linux: /root/inventory.json

  • Windows: C:\Users\Administrator\AppData\Local\.app2container-config\inventory.json

--profile admin-profile

Use this option to specify a named profile to run this command. For more information about named profiles in AWS, see Named profiles in the AWS Command Line Interface User Guide

Options
--deploy

Use this option to deploy directly to your target container management environment (Amazon ECR with Amazon ECS, Amazon EKS, or App Runner).

Note

When you use the --deploy option to deploy directly to target environments, we recommend that you use the --profile option to specify a named profile that has elevated permissions.

--help

Displays the command help.

Output

You have two options for deploying a container to your target environment using the generate app-deployment command.

  • You can use the --deploy option to deploy directly. This option also allows you to create deployments iteratively. For example, after you create an initial Amazon ECS deployment with the --deploy option, then you can rerun the command with --deploy to update your image in Amazon ECS.

  • You can review and customize deployment artifacts, and then deploy using the AWS CLI or AWS console.

Generate container deployment artifacts for customization

app2container generate app-deployment --application-id id

To see the steps App2Container performs and the artifacts that it creates to generate an application deployment for your target container management service, choose the tab that matches your environment:

Amazon ECS

App2Container performs the following tasks and creates artifacts for deployment to Amazon ECS:

Note

You must set the createEcsArtifacts parameter in the deployment.json file to true to generate Amazon ECS artifacts. See Configuring container deployment for more information on how to configure the deployment.json file.

  • Checks for AWS and Docker prerequisites.

  • Creates an Amazon ECR repository.

  • Pushes the container image to the Amazon ECR repository.

  • Generates an Amazon ECS task definition template.

  • Generates a pipeline.json file.

Amazon EKS

App2Container performs the following tasks and creates artifacts for deployment to Amazon EKS:

Note

You must set the createEksArtifacts parameter in the deployment.json file to true to generate Amazon EKS artifacts. See Configuring container deployment for more information on how to configure the deployment.json file.

  • Checks for AWS and Docker prerequisites.

  • Creates an Amazon ECR repository.

  • Pushes the container image to the Amazon ECR repository.

  • Generates a CloudFormation template (eks-master.yml) that creates an EKS cluster, pulls your application container images from Amazon ECR, and deploys your application to the cluster.

  • Generates Kubernetes manifests (eks_deployment.yaml, eks_service.yaml, and eks_ingress.yaml), for post-deployment customizations using a tool such as kubectl.

  • Generates a pipeline.json file.

AWS App Runner

App2Container performs the following tasks and creates artifacts for deployment to AWS App Runner:

Note

You must set the createAppRunnerArtifacts parameter in the deployment.json file to true to generate App Runner artifacts. See Configuring container deployment for more information on how to configure the deployment.json file.

App Runner deployment is currently available for Linux applications only.

  • Checks for AWS and Docker prerequisites.

  • Creates an Amazon ECR repository.

  • Pushes the container image to the Amazon ECR repository.

  • Generates the apprunner.yaml CloudFormation template.

  • Generates a pipeline.json file.

Deploy directly to target environments

app2container generate app-deployment --application-id id --deploy --profile admin-profile

When you run this command with the --deploy option, App2Container uses the same process to validate and customize your deployment resources as it does when you deploy manually. Additionally, it performs the following steps to complete the deployment:

  • Uploads AWS CloudFormation resources to an Amazon S3 bucket, if configured.

  • Creates a CloudFormation stack and deploys your application.

See pipeline.json file for more information about pipeline configuration, and for an example of the deployment.json file.

Examples

Choose the operating system platform tab for the application server or worker machine where you run the command.

Linux

The following example shows the generate app-deployment command with the --application-id parameter.

$ sudo app2container generate app-deployment --application-id java-tomcat-9e8e4799 √ AWS prerequisite check succeeded √ Docker prerequisite check succeeded √ Processing application java-tomcat-9e8e4799... √ Created ECR Repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799 √ Pushed docker image to ECR repository √ Created ECR repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799-fluent-bit √ Pushed docker image 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799-fluent-bit:latest to ECR repository √ Local ECS Task Definition file created √ Uploaded CloudFormation resources to S3 Bucket: app2container-example √ Generated CloudFormation Master template at: /root/app2container/java-tomcat-9e8e4799/EcsDeployment/ecs-master.yml √ Initiated CloudFormation stack creation. This may take a few minutes. To track progress, open the AWS CloudFormation console √ Deploying AWS CloudFormation Stack: <link to stack> √ Stack a2c-java-tomcat-9e8e4799-ECS deployed successfully! √ Updating service Deployment successful for application java-tomcat-9e8e4799 Successfully created ECS infrastructure stack app2container-java-tomcat-9e8e4799-ECS. The URL to your Load Balancer Endpoint is: <your endpoint>.us-east-1.elb.amazonAWS.com The URL to your application log group on CloudWatch is: <log group link>> Set up a pipeline for your application stack using app2container: app2container generate pipeline —application-id java-tomcat-9e8e4799

The following example shows the generate app-deployment command with the --application-id parameter for an application that is deployed to AWS App Runner.

$ sudo app2container generate app-deployment --application-id java-tomcat-9e8e4799 √ AWS pre-requisite check succeeded √ Docker pre-requisite check succeeded √ Created ECR repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799 already √ Pushed docker image to 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799:latest to ECR repository √ Generated AWS App Runner CloudFormation template at /root/app2container/java-tomcat-9e8e4799/AppRunnerDeployment/apprunner.yml CloudFormation templates and additional deployment artifacts generated successfully for application java-tomcat-9e8e4799 You're all set to use AWS CloudFormation to manage your application stack. Next Steps: 1. Edit the CloudFormation template as necessary. 2. Create an application stack using the AWS CLI or the AWS Console. AWS CLI command: aws cloudformation deploy --template-file /root/app2container/java-tomcat-9e8e4799/AppRunnerDeployment/apprunner.yml --capabilities CAPABILITY_IAM --stack-name a2c-java-tomcat-9e8e4799-AppRunner 3. Set up a pipeline for your application stack using app2container: app2container generate pipeline --application-id java-tomcat-9e8e4799

The following example shows the generate app-deployment command with the --application-id parameter and the --deploy option.

$ sudo app2container generate app-deployment --deploy --application-id java-tomcat-9e8e4799 --profile admin-profile √ AWS prerequisite check succeeded √ Docker prerequisite check succeeded √ Processing application java-tomcat-9e8e4799... √ Created ECR Repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799 √ Pushed docker image to ECR repository √ Created ECR repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799-fluent-bit √ Pushed docker image 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799-fluent-bit:latest to ECR repository √ Local ECS Task Definition file created √ Uploaded CloudFormation resources to S3 Bucket: app2container-example √ Generated CloudFormation Master template at: /root/app2container/java-tomcat-9e8e4799/EcsDeployment/ecs-master.yml √ Updating CloudFormation stack √ Initiated CloudFormation stack creation. This may take a few minutes. To track progress, open the AWS CloudFormation console √ Deploying AWS CloudFormation Stack: <link to stack> √ Stack a2c-java-tomcat-9e8e4799-ECS deployed successfully! √ Updating service Deployment successful for application java-tomcat-9e8e4799 Successfully created ECS infrastructure stack app2container-java-tomcat-9e8e4799-ECS. The URL to your Load Balancer Endpoint is: <your endpoint>.us-east-1.elb.amazonaws.com The URL to your application log group on CloudWatch is: <log group link>> Set up a pipeline for your application stack using app2container: app2container generate pipeline —application-id java-tomcat-9e8e4799

The following example shows the generate app-deployment command with the --application-id parameter and the --deploy option for an application that is deployed to AWS App Runner.

$ sudo app2container generate app-deployment --application-id java-tomcat-9e8e4799 --deploy √ AWS pre-requisite check succeeded √ Docker pre-requisite check succeeded √ Created ECR repository 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799 √ Pushed docker image to 123456789012.dkr.ecr.us-west-2.amazonaws.com/java-tomcat-9e8e4799:latest to ECR repository √ Generated AWS App Runner CloudFormation template at /root/app2container/java-tomcat-9e8e4799/AppRunnerDeployment/apprunner.yml Deployment successful for application java-tomcat-9e8e4799 Access your newly deployed App Runner service at the following URL: https://xyz123abc4.us-west-2.awsapprunner.com Stack deployed successfully! Set up a pipeline for your application stack using app2container: app2container generate pipeline --application-id java-tomcat-9e8e4799
Windows

The following example shows the generate app-deployment command with the --application-id parameter.

PS> app2container generate app-deployment --application-id iis-smarts-51d2dbf8 √ AWS pre-requisite check succeeded √ Docker pre-requisite check succeeded √ Created ECR Repository √ Registered ECS Task Definition with ECS √ Uploaded CloudFormation resources to S3 Bucket: app2container\-testing √ Generated CloudFormation Master template at: C:\Users\Administrator\AppData\Local\app2container\iis-smarts-51d2dbf8\EcsDeployment\ecs-master.yml CloudFormation templates and additional deployment artifacts generated successfully for application iis-smarts-51d2dbf8 You're all set to use AWS CloudFormation to manage your application stack. Next Steps: 1. Edit the CloudFormation template as necessary. 2. Create an application stack using the AWS CLI or the AWS Console. AWS CLI command: aws cloudformation deploy --template-file C:\Users\Administrator\AppData\Local\app2container\iis-smarts-51d2dbf8\EcsDeployment\ecs-master.yml --capabilities CAPABILITY_NAMED_IAM --stack-name app2container-iis-smarts-51d2dbf8-ECS 3. Set up a pipeline for your application stack using app2container: app2container generate pipeline --application-id iis-smarts-51d2dbf8

The following example shows the generate app-deployment command with the --application-id parameter and the --deploy option.

PS> app2container generate app-deployment --deploy --application-id iis-smarts-51d2dbf8 --profile admin-profile √ AWS prerequisite check succeeded √ Docker prerequisite check succeeded √ Created ECR Repository √ Registered ECS Task Definition with ECS √ Uploaded CloudFormation resources to S3 Bucket: app2container-example √ Generated CloudFormation Master template at: C:\Users\Administrator\AppData\Local\app2container\iis-smarts-51d2dbf8\EcsDeployment\ecs-master.yml √ Initiated CloudFormation stack creation. This may take a few minutes. Please visit the AWS CloudFormation Console to track progress. ECS deployment successful for application iis-smarts-51d2dbf8 The URL to your Load Balancer Endpoint is: <your endpoint>.us-east-1.elb.amazonaws.com Successfully created ECS stack app2container-iis-smarts-51d2dbf8-ECS. Check the AWS CloudFormation Console for additional details.