{"id":5881,"date":"2023-03-28T10:00:19","date_gmt":"2023-03-28T10:00:19","guid":{"rendered":"https:\/\/tuvoc.com\/?p=5881"},"modified":"2024-11-15T12:53:44","modified_gmt":"2024-11-15T12:53:44","slug":"how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform","status":"publish","type":"post","link":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/","title":{"rendered":"How to Deploy Your Mission-critical Builds in Amazon ECS Using AWS CodePipeline and Terraform?"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">We live in an era where everyone wants everything in no time. Well, in some cases, it can happen, but for some, it requires a set of principles to streamline the whole process to make it possible, not exactly, in no time but faster than the one traditional process. And when it comes to development, DevOps makes this thing possible for developers to meet the app development requirements of clients and prospective app users in a calculative time<\/span><\/p>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">DevOps is a set of principles\/rules that streamline processes for developers and operations teams to break the silos and work asynchronously to achieve the outcome with less time to market. But for it to be achieved, <\/span><span style=\"font-weight: 400;\">they <\/span><span style=\"font-weight: 400;\">require some tools, which we call CI\/CD tools, to create the whole development to deployment\u00a0 pipeline.<\/span><\/p>\n<p>As you can see, the market nowadays is flooded with all kinds of DevOps CI\/CD tools, but choosing the best one to achieve your deployment needs is essential. If your requirement is to continuously deploy your mission-critical builds into the Amazon ECS, we recommend going for the powerful combination of AWS CodePipeline and Terraform to get the efficiency you need. Engaging with <a href=\"https:\/\/www.tuvoc.com\/services\/devops-engineering-services\/continuous-integration-and-continuous-deployment-ci-cd\/\"><strong>CI\/CD integration services<\/strong><\/a> can help streamline this process and optimize your deployment strategy.<\/p>\n<p>Do you want to know how this great combination of AWS CodePipeline and Terraform works together to create a CI\/CD pipeline that boosts app development speed to continuously deploy builds into the Amazon ECS ecosystem? Don\u2019t worry! This whole blog is created for that purpose\u2014to guide you in the right direction! If you&#8217;re looking for expertise, partnering with an <a href=\"https:\/\/www.tuvoc.com\/technologies\/infra-devops\/aws-development\/\"><strong>AWS development company<\/strong><\/a> can make this process even smoother.<\/p>\n<p><span style=\"font-weight: 400;\">So, shall we delve in? Let\u2019s go:<\/span><\/p>\n<h2 style=\"color: #1c5f9b;\">\u00a0What is an AWS CodePipeline?<\/h2>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">AWS CodePipeline is the continuous delivery service enabling DevOps engineers to model, visualize, and streamline the software build release cycle through the quick CI\/CD pipeline creation. So, that means easy development and deployment configuration processes, resulting in a helping hand for releasing software built with less time-to-market.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, let&#8217;s have a look at what else you can do with the AWS CodePipeline:<\/span><\/p>\n<ul>\n<li style=\"list-style-type: disc;\"><span style=\"font-weight: 400;\">Make the most use of your AWS CodePipeline to automate your continuous build release process with source repository using build, test, and deployments. In addition, you can even switch to manual action approval to stop making the processes pass through the pipeline except for the source stage. With automation, as a DevOps engineer, you also get the enablement to release the build when, however the way, on your chosen system and across instances, you would want to.<\/span><\/li>\n<li style=\"list-style-type: disc;\"><span style=\"font-weight: 400;\">With the build being a crucial part, there will come many changes ahead. Hence, it requires readiness to deal with those changes.\u00a0 With CodePipeline, you can achieve it by setting up steps and criteria for each code change to the process.<\/span><\/li>\n<li style=\"list-style-type: disc;\"><span style=\"font-weight: 400;\">Automate your build code while testing and releasing it consistently to give a boost to the release time even with availing new application features to stakeholders.<\/span><\/li>\n<li style=\"list-style-type: disc;\"><span style=\"font-weight: 400;\">Even make use of your preferential source, build, and deployment tools to the AWS Pipeline while checking its supportability for tools, along with integration guides.<\/span><\/li>\n<li style=\"list-style-type: disc;\"><span style=\"font-weight: 400;\">Set up and get real-time monitoring of your build testing and delivery status of the configured pipeline. With real-time monitoring, get real-time alerts on process issues, retry failed actions, and see how many times your source code has been revised at what stage and even manually process from any stage of the pipeline if required.<\/span><\/li>\n<li style=\"list-style-type: disc;\">\n<p style=\"font-weight: 400;\">Check a detailed history of your pipeline, like pipeline start and end time, how long it ran, and execution details (IDs).<\/p>\n<\/li>\n<\/ul>\n<h2 style=\"color: #1c5f9b;\">What is a Terraform?<\/h2>\n<p><span style=\"font-weight: 400;\">Terraform is an Infrastructure-as-Code (IaC) tool that enables developers to configure cloud-based and on-premises resources in an easily understandable file, which then can be versioned, reused, and shared across systems. You can even utilize the continuous cycle to manage your entire infrastructure through a well-configured lifecycle. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">With Terraform, you can manage low-level infrastructure components, like storage, computing, and network resources, along with high-level components, including DNS data and SaaS features.<\/span><\/p>\n<p><b>How does Terraform work?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Terraform mainly works in three critical stages: Write, Plan, and Apply. Let&#8217;s know them in a bit more depth:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Write a terraforming project by defining Terraform configuration and Terraform state file;<\/span><\/li>\n<li aria-level=\"1\"><span style=\"font-weight: 400; list-style-type: disc;\">Plan to review changes done by Terraform to your mission-critical IT infrastructure;<\/span><\/li>\n<li aria-level=\"1\"><span style=\"font-weight: 400; list-style-type: disc;\">Apply the method to enable Terraform to provision infrastructure and make some amendments to the Terraform state files<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Now, you do want to know the benefits to reap out by using AWS CodePipeline and Terraform together! It\u2019s the next!<\/span><b><\/b><\/p>\n<h2 style=\"color: #1c5f9b;\">Why should you use AWS CodePipeline and Terraform Together?<\/h2>\n<p><span style=\"font-weight: 400;\">Using the AWS CodePipeline and Terraform together, you can unlock several benefits, including:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Continuous infrastructure deployments;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Quicker and more efficient deployments;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Improved collaboration and communications amongst developers, operations teams, and app project stakeholders;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Easy build rollbacks and recovery from failures, resulting in a reduction in the app&#8217;s downtime and improved user experience;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\">Easy tracking of code changes and management of infrastructure through a single source of truth.<\/li>\n<\/ul>\n<h2 style=\"color: #1c5f9b;\">How You Can Use AWS CodePipeline and Terraform together to Continuously Deploy Your Build in Amazon ECS<\/h2>\n<p><span style=\"font-weight: 400;\">Now, the moment we all were waiting for! So, let\u2019s dive into this technical guide to continuously deploy the app into Amazon ECS using AWS CodePipeline and Terraform.<\/span><\/p>\n<p><b>Prerequisites<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s go through some prerequisites first before starting with the main process.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">AWS Platform account<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Configured VPCs and Subnets on AWS<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">AWS ECR Repository<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Terraform account<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\">A Python Flask web application with Dockerfile<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Now, let\u2019s take a look at the architectural process we\u2019ll follow throughout the project:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/Tuvoc.com\/wp-content\/uploads\/2023\/03\/Screenshot_1.png\" alt=\"project setup\" width=\"1228\" height=\"440\" class=\"alignnone wp-image-5990 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/Screenshot_1.png 1228w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/Screenshot_1-300x107.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/Screenshot_1-1024x367.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/Screenshot_1-768x275.png 768w\" sizes=\"auto, (max-width: 1228px) 100vw, 1228px\" \/><\/p>\n<p><b>Following image seems more appealing to me.<\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15.png\" alt=\"appealing\" width=\"1999\" height=\"651\" class=\"alignnone wp-image-5884 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15.png 1999w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15-300x98.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15-1024x333.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15-768x250.png 768w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image15-1536x500.png 1536w\" sizes=\"auto, (max-width: 1999px) 100vw, 1999px\" \/><\/p>\n<p><strong>Here, the major components for implementation are:<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">GitHub for the source code repository; (You can have any other repository.)<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Terraform for easy management of resource provisioning.<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">AWS CodePipeline to continuously deploy the app builds;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Amazon ECR (Elastic Container Registry) for repository docker images in a secure, scalable, and reliable manner;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Amazon ECS (Elastic Container Service) to host the application;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">AWS Farget to run container tasks\u00a0 eliminating the need to manage servers or Amazon EC2 instances and VMs&#8217; provisioning, configuration, or scaling needs;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\">\n<p style=\"font-weight: 400;\">ALB (<a href=\"https:\/\/www.tuvoc.com\/aws-developer\/\"><strong>AWS Application<\/strong><\/a> Load Balancer) to pass user requests to running ECS task and balance load.<\/p>\n<\/li>\n<\/ul>\n<h3>STEP 1: Set Up ECS With the Help of Terraform<\/h3>\n<p><span style=\"font-weight: 400;\">Let&#8217;s make the destination ready before delving into the pipeline to streamline the continuous deployment of build releases. And for that, let&#8217;s create start with creating three files:<\/span><br \/>\n<b>1. variables.tf<\/b><b> to store reference variables<\/b><\/p>\n<div>\n<pre><code><region><vpc-id><subnet-1><subnet-2><subnet-n><account-id><region><repository>\r\n<span style=\"font-weight: 400;\">variable \"aws_region\" {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0default = \"&lt;region&gt;\"<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">variable \"vpc_id\" {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0default = \"&lt;vpc-id&gt;\"<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">variable \"subnets\" {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0type = list(string)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0default = [<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\"subnet-&lt;subnet-1&gt;\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\"subnet-&lt;subnet-2&gt;\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\"subnet-&lt;subnet-n&gt;\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0]<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">variable \"image_tag\" {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0default = \"latest\"<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">variable \"image_repo_url\" {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0default = \"&lt;account-id&gt;.dkr.ecr.&lt;region&gt;.amazonaws.com\/&lt;repository&gt;\"<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/repository><\/region><\/account-id><\/subnet-n><\/subnet-2><\/subnet-1><\/vpc-id><\/region>\r\n<\/code><\/pre>\n<\/div>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">This showcases the necessary dependencies.<\/span><\/p>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Now, let&#8217;s associate VPC and subnets with Amazon ECS resources to seamlessly provision the ECS cluster. <\/span><\/p>\n<div style=\"border: 1px solid; padding: 10px; background-color: #b7b70442; margin-bottom: 15px;\">\n<p style=\"font-weight: 800;\">\ud83e\udd14Knowledge Sharing<\/p>\n<p>An Amazon ECS cluster is created by logically grouping compute tasks or services, running on infrastructure and registered to a cluster. Here, then the infrastructure capacity in your ECS cluster will be facilitated by the AWS Fargate &#8211; a serverless infrastructure managed by AWS, a cluster of Amazon EC2 instances managed by you, or a VMs\/On-premises server managed remotely. However, in most cases, therein used Amazon ECS capacity providers for the same.<\/p>\n<\/div>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Well, it can be done in two distinct ways as we are using Terraform, such as:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Provisioning those using Terraform and dynamically associating those to the ECS resources; or<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Use an already configured VPC and subnets.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">As you have gone through the prerequisites already, which you definitely have \ud83d\ude1c, we&#8217;ll pick the second option.<\/span><\/p>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">As we are using containers for deploying the application into ECS, we have to push the docker images to a content registry system, like Docker Hub, Elastic Container Register (ECR), Google Container Registry (GCR), etc. But we are using ECR so we&#8217;ll push all those images into the ECR<\/span>.<\/p>\n<p><span style=\"font-weight: 400;\">To do so, we&#8217;ll create an ECR repository. Well, whether to keep the repository private or public is totally up to your requirements. Here, we&#8217;re going to keep the ECR repository, Private. See below:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image47.png\" alt=\"create repository\" width=\"858\" height=\"707\" class=\"alignnone wp-image-5889 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image47.png 858w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image47-300x247.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image47-768x633.png 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Here, we\u2019ve named the url as \u201c<span style=\"background-color: #d9d9d9;\">image_repo_url<\/span><\/span><span style=\"font-weight: 400;\">\u201d above as shown in the image.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A point to remember! From now on, when we build and push a new image into the ECR, ensure to tag the image. Also, we&#8217;ll name every new version tag as the <span style=\"background-color: #d9d9d9;\">latest <\/span><\/span><span style=\"font-weight: 400;\">with the intention to overwrite the previous image versions.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, all required variables for the ECS cluster creation are ready to use!<\/span><\/p>\n<p><b>2. provider.tf<\/b><b> to set up providers<\/b><\/p>\n<div>\n<pre><code>provider \"aws\" {\r\n  region = var.aws_region\r\n}<\/code><\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">When planning to run CI\/CD terraform effectively, it&#8217;s important to log into the AWS account locally. Confirm that, we&#8217; run the following command:<\/span><span style=\"font-family: Consolas, Monaco, monospace;\"><\/span><\/p>\n<div>\n<pre><span style=\"font-weight: 400;\">$ aws configure<\/span><\/pre>\n<\/div>\n<div><\/div>\n<div>\n<p style=\"font-weight: 400;\">Also, refer to this guide to use the AWS CLI effortlessly<\/p>\n<\/div>\n<div><\/div>\n<div>\n<p style=\"font-weight: 400;\">2. ecs.tf to set up resources<\/p>\n<\/div>\n<div>\n<pre><code>resource \"aws_ecs_cluster\" \"flask_app_demo\" {\r\n  name = \"flask-app-demo\"\r\n}\r\nresource \"aws_ecs_task_definition\" \"flask_app_demo\" {\r\n  family                   = \"flask-app-demo\"\r\n  network_mode             = \"awsvpc\"\r\n  requires_compatibilities = [\"FARGATE\"]\r\n  cpu                      = \"256\"\r\n  memory                   = \"512\"\r\n  container_definitions = DEFINITION\r\n[\r\n  {\r\n    \"name\": \"flask-app-demo\",\r\n    \"image\": \"${var.image_repo_url}:${var.image_tag}\",\r\n    \"essential\": true,\r\n    \"portMappings\": [\r\n      {\r\n        \"containerPort\": 5000,\r\n        \"hostPort\": 5000\r\n      }\r\n    ],\r\n    \"logConfiguration\": {\r\n      \"logDriver\": \"awslogs\",\r\n      \"options\": {\r\n        \"awslogs-group\": \"${aws_cloudwatch_log_group.flask_app_demo.name}\",\r\n        \"awslogs-region\": \"${var.aws_region}\",\r\n        \"awslogs-stream-prefix\": \"flask-app-demo\"\r\n      }\r\n    }\r\n  }\r\n]\r\nDEFINITION\r\n  execution_role_arn = aws_iam_role.task_definition_role.arn\r\n  runtime_platform {\r\n    operating_system_family = \"LINUX\"\r\n    cpu_architecture        = \"X86_64\"\r\n  }\r\n}\r\nresource \"aws_cloudwatch_log_group\" \"flask_app_demo\" {\r\n  name = \"\/ecs\/flask-app-demo\"\r\n}\r\nresource \"aws_ecs_service\" \"flask_app_demo\" {\r\n  name            = \"flask-app-demo\"\r\n  cluster         = aws_ecs_cluster.flask_app_demo.id\r\n  task_definition = aws_ecs_task_definition.flask_app_demo.arn\r\n  desired_count   = 1\r\n  launch_type     = \"FARGATE\"\r\n  network_configuration {\r\n    subnets         = var.subnets\r\n    security_groups = [aws_security_group.flask_app_demo.id]\r\n    assign_public_ip = true\r\n  }\r\n  load_balancer {\r\n    target_group_arn = aws_lb_target_group.flask_app_demo.arn\r\n    container_name   = \"flask-app-demo\"\r\n    container_port   = 5000\r\n  }\r\n}\r\nresource \"aws_security_group\" \"flask_app_demo\" {\r\n  name        = \"flask-app-demo\"\r\n  description = \"Allow inbound traffic to flask app\"\r\n  vpc_id      = var.vpc_id\r\n  ingress {\r\n    description      = \"Allow HTTP from anywhere\"\r\n    from_port        = 0\r\n    to_port          = 0\r\n    protocol         = \"-1\"\r\n    cidr_blocks      = [\"0.0.0.0\/0\"]\r\n    ipv6_cidr_blocks = [\"::\/0\"]\r\n  }\r\n   egress {\r\n    from_port        = 0\r\n    to_port          = 0\r\n    protocol         = \"-1\"\r\n    cidr_blocks      = [\"0.0.0.0\/0\"]\r\n    ipv6_cidr_blocks = [\"::\/0\"]\r\n  }\r\n}\r\nresource \"aws_lb_target_group\" \"flask_app_demo\" {\r\n  name        = \"flask-app-demo\"\r\n  port        = 5000\r\n  protocol    = \"HTTP\"\r\n  vpc_id      = var.vpc_id\r\n  target_type = \"ip\"\r\n  health_check {\r\n    path                = \"\/\"\r\n    interval            = 30\r\n    timeout             = 10\r\n    healthy_threshold   = 2\r\n    unhealthy_threshold = 2\r\n  }\r\n}\r\nresource \"aws_lb\" \"flask_app_demo\" {\r\n  name               = \"flask-app-demo\"\r\n  internal           = false\r\n  load_balancer_type = \"application\"\r\n  security_groups    = [aws_security_group.flask_app_demo.id]\r\n  subnets            = var.subnets\r\n  enable_deletion_protection = false\r\n  tags = {\r\n    Name = \"flask-app-demo\"\r\n  }\r\n}\r\nresource \"aws_lb_listener\" \"flask_app_demo\" {\r\n  load_balancer_arn = aws_lb.flask_app_demo.arn\r\n  port              = \"80\"\r\n  protocol          = \"HTTP\"\r\n  default_action {\r\n    type             = \"forward\"\r\n    target_group_arn = aws_lb_target_group.flask_app_demo.arn\r\n  }\r\n}\r\nresource \"aws_lb_listener_rule\" \"flask_app_demo\" {\r\n  listener_arn = aws_lb_listener.flask_app_demo.arn\r\n  priority     = 1\r\n  action {\r\n    type             = \"forward\"\r\n    target_group_arn = aws_lb_target_group.flask_app_demo.arn\r\n  }\r\n  condition {\r\n    path_pattern {\r\n      values = [\"\/\"]\r\n    }\r\n  }\r\n}\r\nresource \"aws_iam_role\" \"task_definition_role\" {\r\n  name = \"flask_demo_task_definition\"\r\n  assume_role_policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Action\": \"sts:AssumeRole\",\r\n      \"Principal\": {\r\n        \"Service\": \"ecs-tasks.amazonaws.com\"\r\n      },\r\n      \"Effect\": \"Allow\",\r\n      \"Sid\": \"\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\nresource \"aws_iam_role_policy\" \"task_definition_policy\" {\r\n  name = \"flask_demo_task_definition_policy\"\r\n  role = aws_iam_role.task_definition_role.id\r\n  policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"ecr:BatchCheckLayerAvailability\",\r\n        \"ecr:GetAuthorizationToken\",\r\n        \"ecr:GetDownloadUrlForLayer\",\r\n        \"ecr:BatchGetImage\",\r\n        \"logs:CreateLogStream\",\r\n        \"logs:PutLogEvents\",\r\n        \"secretsmanager:GetSecretValue\",\r\n        \"ssm:GetParameters\"\r\n      ],\r\n      \"Resource\": [\r\n        \"*\"\r\n      ]\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\n<\/code><\/pre>\n<\/div>\n<div>\n<p style=\"font-weight: 400;\">This block of code contains three types of configurations.<\/p>\n<\/div>\n<div><\/div>\n<div><b>I.\u00a0 \u00a0A configuration of all resources to create an ECS cluster.<\/b><\/div>\n<div><span style=\"font-weight: 400;\">covering first 1-58 lines of code, where:<\/span><\/div>\n<div>\n<ol>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"2\"><span style=\"font-weight: 400;\">line 1-3 to create a cluster &#8220;<span style=\"background-color: #d9d9d9;\">flash-app-demo<\/span><\/span><span style=\"font-weight: 400;\">&#8220;)<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"2\"><span style=\"font-weight: 400;\">line 4-38 for task definition<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"2\"><span style=\"font-weight: 400;\">line 39-41 to create a CloudWatch log group for cluster monitoring<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"2\"><span style=\"font-weight: 400;\">line 42-58 to create an ECS service<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Here, Amazon ECS service can be used to process and manage specific task definition instances simultaneously inside the cluster.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In case of one task failure, the Amazon ECS service scheduler instantly launches another instance for replacing the same.<\/span><\/p>\n<p><mark><b>\ud83d\udcddNote:<\/b><span style=\"font-weight: 400;\"> the <\/span><span style=\"font-weight: 400; background-color: #d9d9d9;\">launch_type<\/span><span style=\"font-weight: 400;\"> should be FARGATE to ensure that the build is deployed into the AWS Fargate service. Amongst various reasons, Farget has been chosen for easy management soon as it eliminates much of the overhead for the same.<\/span><\/mark><\/p>\n<p><b>II.\u00a0 \u00a0Network-based configuration<\/b><\/p>\n<p><span style=\"font-weight: 400;\">After those lines, L59-125 focuses on the Network configuration. If being too specific, it shows the configuration of the AWS security group using Terraform, and it enables us to limit network boundaries for incoming and outgoing traffic.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In addition to that, we&#8217;ll also set up load-balancing resources to have a sight on traffic and create a load balancer for the application. For more information, do refer to the <\/span><a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/aws\/latest\/docs\/resources\/lb\"><span style=\"font-weight: 400;\">Terraform guide<\/span><\/a><span style=\"font-weight: 400;\"> for the same.<\/span><\/p>\n<p><b>III.\u00a0 IAM configuration<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Now, further, the remaining code lines are for configuring the ECS permission resources that can engage with ECR for logging.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s do the AWS configuration:<\/span><\/p>\n<ul>\n<li style=\"list-style-type: disc;\">\n<p style=\"font-weight: 400;\">Initializing the directory: <span style=\"font-weight: 400;\">$ terraform init<\/span><\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image7.png\" alt=\"provide pluging\" width=\"1074\" height=\"442\" class=\"alignnone wp-image-5894 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image7.png 1074w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image7-300x123.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image7-1024x421.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image7-768x316.png 768w\" sizes=\"auto, (max-width: 1074px) 100vw, 1074px\" \/><\/p>\n<ul>\n<li style=\"list-style-type: disc;\">Plan to create the infrastructure: $ terraform plan<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11.png\" alt=\" plugin code\" width=\"1102\" height=\"751\" class=\"alignnone wp-image-5895 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11.png 1102w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-300x204.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-1024x698.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-768x523.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image24.png\" alt=\"code\" width=\"1104\" height=\"762\" class=\"alignnone wp-image-5896 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image24.png 1104w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image24-300x207.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image24-1024x707.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image24-768x530.png 768w\" sizes=\"auto, (max-width: 1104px) 100vw, 1104px\" \/><\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/Tuvoc.com\/wp-content\/uploads\/2023\/03\/image11.png\" alt=\"code ftp\" width=\"1102\" height=\"751\" class=\"alignnone wp-image-5895 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11.png 1102w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-300x204.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-1024x698.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image11-768x523.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image14.png\" alt=\"coding\" width=\"1104\" height=\"762\" class=\"alignnone wp-image-5897 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image14.png 1104w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image14-300x207.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image14-1024x707.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image14-768x530.png 768w\" sizes=\"auto, (max-width: 1104px) 100vw, 1104px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image12.png\" alt=\"coding\" width=\"1104\" height=\"762\" class=\"alignnone wp-image-5898 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image12.png 1104w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image12-300x207.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image12-1024x707.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image12-768x530.png 768w\" sizes=\"auto, (max-width: 1104px) 100vw, 1104px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, you can see the Terraform generated files:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image3.png\" alt=\"Terraform generated files\" width=\"928\" height=\"197\" class=\"alignnone wp-image-5999 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image3.png 928w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image3-300x64.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image3-768x163.png 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, it\u2019s time to verify the implementation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For that, go to the Amazon Elastic Container Services page to start with the verification process:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image23.png\" alt=\"all clusters\" width=\"1200\" height=\"755\" class=\"alignnone wp-image-5900 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image23.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image23-300x189.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image23-1024x644.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image23-768x483.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image32.png\" alt=\"task definiens\" width=\"1200\" height=\"755\" class=\"alignnone wp-image-5901 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image32.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image32-300x189.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image32-1024x644.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image32-768x483.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image31.png\" alt=\"flask app demo\" width=\"1200\" height=\"815\" class=\"alignnone wp-image-5902 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image31.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image31-300x204.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image31-1024x695.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image31-768x522.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Can you see the task definition linked to the appropriate image in the ECR cluster? Yes! Great Job!<\/span><\/p>\n<p><b>Level 1 achieved!<\/b><span style=\"font-weight: 400;\"> \ud83e\udd73 <\/span><\/p>\n<p><span style=\"font-weight: 400;\">But note that \ud83d\udcdd, this is still not in its working phase as it is still pending to push the flask application in.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\ud83d\udea8Be careful of the information you make available.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Worry not! Let&#8217;s move to the next step, which is the deployment stage!<\/span><\/p>\n<div style=\"border: 1px solid; padding: 10px; background-color: #e1ced1; margin-bottom: 15px;\">\n<p style=\"font-weight: 800;\">Bonus \ud83c\udf81:<\/p>\n<p>In addition to this method, you can also create a backend.tf file to store the Terraform State configuration file on the cloud ecosystem (Amazon S3, to be precise).<\/p>\n<\/div>\n<h3 style=\"color: #1c5f9b;\">STEP 2: Configure AWS CodePipeline Using Terraform<\/h3>\n<p><span style=\"font-weight: 400;\">It&#8217;s time to prepare the Flask application and push it into the docket.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s start with running your mission-critical build locally: <span style=\"background-color: #d9d9d9;\">$ pip install flask<\/span><\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"font-weight: 400;\">And then create a basic Flask app: <span style=\"background-color: #d9d9d9;\">flask_app\/app.py <\/span><\/p>\n<div>\n<pre><code>from flask import Flask\r\napp = Flask(__name__)\r\n@app.route(\"\/\")\r\ndef hello():\r\n    return \"Yayy, we have the 1st version of our flask application\"\r\nif __name__ == \"__main__\":\r\n    app.run(host=\"0.0.0.0\")\r\n<\/code><\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">Write a command to run the app: <\/span><span style=\"background-color: #d9d9d9;\">$ python3 flask_app\/app.py<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image43.png\" alt=\"command run\" width=\"1026\" height=\"206\" class=\"alignnone wp-image-5904 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image43.png 1026w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image43-300x60.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image43-1024x206.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image43-768x154.png 768w\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image5.png\" alt=\"run command\" width=\"1200\" height=\"749\" class=\"alignnone wp-image-5905 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image5.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image5-300x187.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image5-1024x639.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image5-768x479.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, let\u2019s dockerize the app with the command to <\/span><span style=\"font-weight: 400;\">create a <span style=\"background-color: #d9d9d9;\">Dockerfile<\/span><\/span><span style=\"font-weight: 400;\">\u00a0:<span style=\"background-color: #d9d9d9;\">flask_app\/Dockerfile<\/span><\/span><span style=\"font-family: Consolas, Monaco, monospace; font-size: 17px;\"><\/span><\/p>\n<div>\n<pre><code>FROM public.ecr.aws\/bitnami\/python:3.9\r\nRUN pip install flask\r\nCOPY app.py .\/app.py\r\nCMD [\"python\", \"app.py\"]<\/code><\/pre>\n<\/div>\n<p><i><span style=\"font-weight: 400;\">Caution: Here, we avoided using FROM python: 3.8 as the Docker hub has some download restrictions, resulting in an app building up the block.<\/span><\/i><\/p>\n<div>\n<p><span style=\"font-weight: 400;\">Now, let&#8217;s build the docker image with the command: <span style=\"background-color: #d9d9d9;\">docker build -t flask-application-demo:latest .\/flask_app\/<\/span><\/span><\/p>\n<\/div>\n<div>\n<p><span style=\"font-weight: 400;\">This will create the <span style=\"background-color: #d9d9d9;\">flash-application-demo <\/span><\/span><span style=\"font-weight: 400;\">image and tag it with the label <span style=\"background-color: #d9d9d9;\">latest<\/span><\/span><span style=\"font-weight: 400;\">, as we&#8217;ve discussed in the beginning to overlap the older image.<\/span><\/p>\n<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image9.png\" alt=\"older image\" width=\"1200\" height=\"749\" class=\"alignnone wp-image-5915 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image9.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image9-300x187.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image9-1024x639.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image9-768x479.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/div>\n<div>\n<p><span style=\"font-weight: 400; margin-top: 15px;\">Want to know whether the image has been built or not? Let&#8217;s check it: <span style=\"background-color: #d9d9d9;\">$ docker image ls<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image48.png\" alt=\"docker image ls\" width=\"1035\" height=\"86\" class=\"alignnone wp-image-5917 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image48.png 1035w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image48-300x25.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image48-1024x85.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image48-768x64.png 768w\" sizes=\"auto, (max-width: 1035px) 100vw, 1035px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s confirmed now that the Flask app image has been created! Hurray!! So, it&#8217;s time to run the Docker container: <\/span><span style=\"font-weight: 400;\">$ docker run -d -p 5000:5000 flask-application-demo<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image46.png\" alt=\" image ls\" width=\"1200\" height=\"43\" class=\"alignnone wp-image-5918 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image46.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image46-300x11.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image46-1024x37.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image46-768x28.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">At last visit the local URL you\u2019ve been using to check the ready build of the Flask application.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As the local setup of the app is ready, it&#8217;s time to move ahead toward the CodePipeline configuration to deploy the build as we push it to GitHub.<\/span><\/p>\n<\/div>\n<div>\n<p style=\"font-weight: 400;\">Check-in time to see how the directory tree looks like:<\/p>\n<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image8-1.png\" alt=\"directory tree\" width=\"829\" height=\"255\" class=\"alignnone wp-image-6000 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image8-1.png 829w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image8-1-300x92.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image8-1-768x236.png 768w\" sizes=\"auto, (max-width: 829px) 100vw, 829px\" \/><\/div>\n<div><\/div>\n<div style=\"margin-top: 15px;\">\n<p><b>The BuildSpec Activities in\u00a0 AWS CodeBuild<\/b><\/p>\n<\/div>\n<div>\n<p><span style=\"font-weight: 400;\">It stands for build specification made of a set of build commands and relatable YAML formatted settings used by CodeBuild to successfully run the build.<\/span><\/p>\n<\/div>\n<div>\n<p><span style=\"font-weight: 400;\">Apart from the locals, you can even use BuildSpec to build images that we&#8217;ve just done locally and push them to ECS task definitions to deploy the basic Flask application<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s have a look at the buildspec.yaml code fil<\/span><\/p>\n<div>\n<pre><code># Buildspec to pull the latest version of the Docker image from docker\r\nhub and deploy it to the ECS cluster\r\nversion: 0.2\r\nphases:\r\n  install:\r\n    runtime-versions:\r\n      docker: 18\r\n  pre_build:\r\n    commands:\r\n      - echo Logging in to Amazon ECR....\r\n      - echo $AWS_ACCOUNT_ID - $AWS_DEFAULT_REGION - $IMAGE_REPO_NAME - \r\n$IMAGE_TAG\r\n      - aws --version\r\n      - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker\r\n login --username AWS --password-stdin\r\n $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\r\n      - export\r\n REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/\r\n$IMAGE_REPO_NAME\r\n      - echo Build started on `date`\r\n      - echo Building the Docker image...\r\n      - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .\/flask_app\r\n      - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $REPOSITORY_URI:$IMAGE_TAG\r\n  build:\r\n    commands:\r\n      - echo Pushing the Docker image to ECR...\r\n      - echo $REPOSITORY_URI:$IMAGE_TAG\r\n      - docker push $REPOSITORY_URI:$IMAGE_TAG\r\n  post_build:\r\n    commands:\r\n      - echo Build completed on `date`\r\n      - echo Deploying new task definition $IMAGE_TAG to ECS cluster...\r\n      - echo ECS_CLUSTER_NAME - $ECS_SERVICE_NAME, ECS_SERVICE_NAME\r\n - $ECS_SERVICE_NAME\r\n      - aws ecs update-service --cluster $ECS_CLUSTER_NAME --service\r\n $ECS_SERVICE_NAME --task-definition $ECS_TASK_DEFINITION \r\n --force-new-deployment\r\n       - echo ECS service $ECS_SERVICE_NAME updated\r\n<\/code><\/pre>\n<\/div>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Here, the buildspec is parted into four stages:<\/span><\/p>\n<ol>\n<li style=\"list-style-type: auto;\"><span style=\"font-weight: 400; background-color: #d9d9d9;\">Install<\/span><span style=\"font-weight: 400;\"> packages<\/span><\/li>\n<li style=\"list-style-type: auto;\"><span style=\"font-weight: 400; background-color: #d9d9d9;\">pre_build<\/span><span style=\"font-weight: 400;\"> to log into the ECR and create the image with the Dockerfile stored in the flask_app folder.<\/span><\/li>\n<li style=\"list-style-type: auto;\"><span style=\"font-weight: 400; background-color: #d9d9d9;\">build<\/span><span style=\"font-weight: 400;\"> to push the images to ECR.<\/span><\/li>\n<li style=\"list-style-type: auto;\"><span style=\"font-weight: 400; background-color: #d9d9d9;\">post_build<\/span><span style=\"font-weight: 400;\"> to update the ECS task definition to add the latest version of the flask app image in ECR overlapping the old image.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It does require some variables to build and deploy the application, which will be covered in the section.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Again check the directory tree for more confirmation: <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image34-1.png\" alt=\"hunt directory\" width=\"832\" height=\"273\" class=\"alignnone wp-image-5922 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image34-1.png 832w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image34-1-300x98.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image34-1-768x252.png 768w\" sizes=\"auto, (max-width: 832px) 100vw, 832px\" \/><\/p>\n<p><b>Let\u2019s Finally Set Up the AWS CodePipeline<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The pipeline we are going to configure will be solely responsible for linking AWS to a GitHub repository, finding the mission-critical app, and implementing and deploying it as per the given buildspec setup.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As discussed above, let&#8217;s first create some variables in the file <\/span><b>variables.tf<\/b><span style=\"font-weight: 400;\">:<\/span><\/p>\n<div>\n<pre><code>variable \"aws_account_id\" {\r\n  default = \"902107193506\"\r\n}\r\nvariable \"aws_region\" {\r\n  default = \"us-west-2\"\r\n}\r\nvariable \"vpc_id\" {\r\n  default = \"<vpc-id>\"\r\n}\r\nvariable \"subnets\" {\r\n  type = list(string)\r\n  default = [\r\n    \"subnet-<subnet-1>\",\r\n    \"subnet-<subnet-2>\",\r\n    \"subnet-<subnet-n>\"\r\n  ]\r\n}\r\nvariable \"image_repo_name\" {\r\n  default = \"flask-application-demo\"\r\n}\r\nvariable \"image_tag\" {\r\n  default = \"latest\"\r\n}\r\nvariable \"image_repo_url\" {\r\n  default = \"<account-id>.dkr.ecr.<region>.amazonaws.com\/<repository>\"\r\n}\r\nvariable \"github_repo_owner\" {\r\n  default = \"m3rryqold\"\r\n}\r\nvariable \"github_repo_name\" {\r\n  default = \"terraform-ecs-codepipeline-flask-demo\"\r\n}\r\nvariable \"github_branch\" {\r\n  default = \"main\"\r\n}\r\n<\/repository><\/region><\/account-id><\/subnet-n><\/subnet-2><\/subnet-1><\/vpc-id><\/code><\/pre>\n<\/div>\n<p style=\"font-weight: 400;\">Now, the CodePipeline has been loaded with some required variables, especially for the GitHub repository. Moving on to the next step to create the <span style=\"background-color: #d9d9d9;\">main.tf<\/span><span style=\"font-weight: 400;\">\u00a0file:<\/span><\/p>\n<\/div>\n<div>\n<pre><code>resource \"aws_codepipeline\" \"codepipeline\" {\r\n  name     = \"flask_demo_pipeline\"\r\n  role_arn = aws_iam_role.codepipeline_role.arn\r\n  artifact_store {\r\n    location = aws_s3_bucket.codepipeline_bucket.bucket\r\n    type     = \"S3\"\r\n    encryption_key {\r\n      id   = data.aws_kms_alias.s3kmskey.arn\r\n      type = \"KMS\"\r\n    }\r\n  }\r\n  stage {\r\n    name = \"Source\"\r\n    action {\r\n      name             = \"Source\"\r\n      category         = \"Source\"\r\n      owner            = \"AWS\"\r\n      provider         = \"CodeStarSourceConnection\"\r\n      version          = \"1\"\r\n      output_artifacts = [\"source_output\"]\r\n      configuration = {\r\n        ConnectionArn    = aws_codestarconnections_connection.example.arn\r\n        FullRepositoryId = \"${var.github_repo_owner}\/${var.github_repo_name}\"\r\n        BranchName       = var.github_branch\r\n      }\r\n    }\r\n  }\r\n  stage {\r\n    name = \"Build\"\r\n    action {\r\n      name             = \"Build\"\r\n      category         = \"Build\"\r\n      owner            = \"AWS\"\r\n      provider         = \"CodeBuild\"\r\n      input_artifacts  = [\"source_output\"]\r\n      output_artifacts = [\"build_output\"]\r\n      version          = \"1\"\r\n      configuration = {\r\n        ProjectName = aws_codebuild_project.flask_app.name\r\n      }\r\n    }\r\n  }\r\n}\r\nresource \"aws_codestarconnections_connection\" \"example\" {\r\n  name          = \"flask-demo-connection\"\r\n  provider_type = \"GitHub\"\r\n}\r\nresource \"aws_s3_bucket\" \"codepipeline_bucket\" {\r\n  bucket = \"flask-demo-codepipeline-bucket\"\r\n}\r\nresource \"aws_s3_bucket_acl\" \"codepipeline_bucket_acl\" {\r\n  bucket = aws_s3_bucket.codepipeline_bucket.id\r\n  acl    = \"private\"\r\n}\r\nresource \"aws_iam_role\" \"codepipeline_role\" {\r\n  name = \"flask_demo_codepipeline_role\"\r\n  assume_role_policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Sid\": \"TrustPolicyStatementThatAllowsEC2ServiceToAssumeTheAttachedRole\",\r\n      \"Effect\": \"Allow\",\r\n      \"Principal\": {\r\n        \"Service\": \"codepipeline.amazonaws.com\"\r\n      },\r\n      \"Action\": \"sts:AssumeRole\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\nresource \"aws_iam_role_policy\" \"codepipeline_policy\" {\r\n  name = \"flask_demo_codepipeline_policy\"\r\n  role = aws_iam_role.codepipeline_role.id\r\n  policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Effect\":\"Allow\",\r\n      \"Action\": [\r\n        \"s3:GetObject\",\r\n        \"s3:GetObjectVersion\",\r\n        \"s3:GetBucketVersioning\",\r\n        \"s3:PutObjectAcl\",\r\n        \"s3:PutObject\",\r\n        \"iam:GetRole\",\r\n        \"iam:PassRole\"\r\n      ],\r\n      \"Resource\": [\r\n        \"${aws_s3_bucket.codepipeline_bucket.arn}\",\r\n        \"${aws_s3_bucket.codepipeline_bucket.arn}\/*\",\r\n        \"*\"\r\n      ]\r\n    },\r\n    {\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"codestar-connections:UseConnection\"\r\n      ],\r\n      \"Resource\": \"${aws_codestarconnections_connection.example.arn}\"\r\n    },\r\n    {\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"codebuild:BatchGetBuilds\",\r\n        \"codebuild:StartBuild\"\r\n      ],\r\n      \"Resource\": \"*\"\r\n    },\r\n    {\r\n      \"Effect\": \"Allow\",\r\n      \"Action\": [\r\n        \"cloudformation:DescribeStacks\",\r\n        \"kms:GenerateDataKey\",\r\n        \"iam:GetRole\",\r\n        \"iam:PassRole\"\r\n      ],\r\n      \"Resource\": \"*\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\nresource \"aws_codebuild_project\" \"flask_app\" {\r\n  name          = \"flask-app-demo\"\r\n  description   = \"Builds a flask application\"\r\n  service_role  = aws_iam_role.codebuild_role.arn\r\n  build_timeout = \"5\"\r\n  artifacts {\r\n    type = \"CODEPIPELINE\"\r\n  }\r\n  environment {\r\n    compute_type    = \"BUILD_GENERAL1_SMALL\"\r\n    image           = \"aws\/codebuild\/standard:2.0\"\r\n    type            = \"LINUX_CONTAINER\"\r\n    privileged_mode = true\r\n    environment_variable {\r\n      name  = \"AWS_ACCOUNT_ID\"\r\n      value = var.aws_account_id\r\n    }\r\n    environment_variable {\r\n      name  = \"AWS_DEFAULT_REGION\"\r\n      value = var.aws_region\r\n    }\r\n    environment_variable {\r\n      name  = \"IMAGE_REPO_NAME\"\r\n      value = var.image_repo_name\r\n    }\r\n    environment_variable {\r\n      name  = \"IMAGE_TAG\"\r\n      value = var.image_tag\r\n    }\r\n    environment_variable {\r\n      name  = \"ECS_CLUSTER_NAME\"\r\n      value = aws_ecs_cluster.flask_app_demo.name\r\n    }\r\n    environment_variable {\r\n      name  = \"ECS_SERVICE_NAME\"\r\n      value = aws_ecs_service.flask_app_demo.name\r\n    }\r\n    environment_variable {\r\n      name  = \"ECS_TASK_DEFINITION\"\r\n      value = aws_ecs_task_definition.flask_app_demo.family\r\n    }\r\n  }\r\n  source {\r\n    type      = \"CODEPIPELINE\"\r\n    buildspec = \"buildspec.yml\"\r\n  }\r\n}\r\nresource \"aws_iam_role\" \"codebuild_role\" {\r\n  name = \"flask_demo_codebuild_role\"\r\n  assume_role_policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Action\": \"sts:AssumeRole\",\r\n      \"Principal\": {\r\n        \"Service\": \"codebuild.amazonaws.com\"\r\n      },\r\n      \"Effect\": \"Allow\",\r\n      \"Sid\": \"TrustPolicyStatementThatAllowsEC2ServiceToAssumeTheAttachedRole\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\nresource \"aws_iam_role_policy\" \"codebuild_policy\" {\r\n  name = \"flask_demo_codebuild_policy\"\r\n  role = aws_iam_role.codebuild_role.id\r\n  policy = EOF\r\n{\r\n  \"Version\": \"2012-10-17\",\r\n  \"Statement\": [\r\n    {\r\n      \"Action\": [\r\n        \"logs:CreateLogGroup\",\r\n        \"logs:CreateLogStream\",\r\n        \"logs:PutLogEvents\"\r\n      ],\r\n      \"Resource\": \"arn:aws:logs:*:*:*\",\r\n      \"Effect\": \"Allow\"\r\n    },\r\n    {\r\n      \"Action\": [\r\n        \"s3:GetObject\",\r\n        \"s3:GetObjectVersion\",\r\n        \"s3:GetBucketVersioning\"\r\n      ],\r\n      \"Resource\": [\r\n        \"arn:aws:s3:::${aws_s3_bucket.codepipeline_bucket.bucket}\",\r\n        \"arn:aws:s3:::${aws_s3_bucket.codepipeline_bucket.bucket}\/*\"\r\n      ],\r\n      \"Effect\": \"Allow\"\r\n    },\r\n    {\r\n      \"Action\": [\r\n        \"ecr:BatchCheckLayerAvailability\",\r\n        \"ecr:CompleteLayerUpload\",\r\n        \"ecr:GetAuthorizationToken\",\r\n        \"ecr:InitiateLayerUpload\",\r\n        \"ecr:PutImage\",\r\n        \"ecr:UploadLayerPart\"\r\n      ],\r\n      \"Resource\": [\r\n        \"*\"\r\n      ],\r\n        \"Effect\": \"Allow\"\r\n    },\r\n    {\r\n      \"Action\": [\r\n        \"ecs:UpdateService\",\r\n        \"iam:GetRole\",\r\n        \"iam:PassRole\"\r\n      ],\r\n      \"Resource\": [\r\n        \"*\"\r\n      ],\r\n        \"Effect\": \"Allow\"\r\n    }\r\n  ]\r\n}\r\nEOF\r\n}\r\ndata \"aws_kms_alias\" \"s3kmskey\" {\r\n  name = \"alias\/flask_app_s3kmskey\"\r\n}<\/code><\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">Wow! Such a big block of code. \ud83d\ude32 Let&#8217;s do the postmortem of it to understand it step-by-step.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If checking the 8th line, you&#8217;ll find referencing the encryption key for the data linked in the L248. This is necessary to detect as it will become our key to securing the GitHub action artifacts located in the Amazon S3 buckets. Make a deep dive into the KMS through the official source!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Follow the below steps to create a KMS key.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image16.png\" alt=\"KMS\" width=\"959\" height=\"357\" class=\"alignnone wp-image-5923 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image16.png 959w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image16-300x112.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image16-768x286.png 768w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image18.png\" alt=\"KMS Key\" width=\"1200\" height=\"406\" class=\"alignnone wp-image-5924 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image18.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image18-300x102.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image18-1024x346.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image18-768x260.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image2.png\" alt=\"configure key\" width=\"1200\" height=\"545\" class=\"alignnone wp-image-5925 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image2.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image2-300x136.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image2-1024x465.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image2-768x349.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image20.png\" alt=\"add labels\" width=\"1200\" height=\"644\" class=\"alignnone wp-image-5926 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image20.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image20-300x161.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image20-1024x550.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image20-768x412.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image17.png\" alt=\"key\" width=\"1200\" height=\"674\" class=\"alignnone wp-image-5927 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image17.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image17-300x169.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image17-1024x575.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image17-768x431.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">So many processes blowing off \ud83e\udd2four minds, aren\u2019t they? Let&#8217;s take a detour of the code to understand it nicely.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The L1-43 are used to create CodePipeline resources, each linked in different stages. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Refer to this <\/span><a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/aws\/latest\/docs\/resources\/codepipeline\"><span style=\"font-weight: 400;\">link<\/span><\/a><span style=\"font-weight: 400;\"> to find Terraform resources.<\/span><\/p>\n<div style=\"border: 1px solid; padding: 10px; margin-bottom: 15px;\">The <span style=\"font-weight: 400;\"><span style=\"background-color: #d9d9d9;\">artifactStores <\/span><\/span> field stores the artifact bucket type and the pipeline location with necessary actions in the same AWS Region as others. For adding actions in the different AWS Region from the pipeline than the <span style=\"font-weight: 400;\"><span style=\"background-color: #d9d9d9;\">artifactStores <\/span><\/span>to be used for mapping the artifact bucket for that Region and others, the actions are expected to be executed.<\/div>\n<div>\n<p style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Lines 12-41 are used to define two stages in the CodePipeline.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Apart from that, the <span style=\"background-color: #d9d9d9;\">deploy <\/span><\/span><span style=\"font-weight: 400;\">stage plays a pretty important role in the CodePipeline configuration. Therefore, it is greyed out in the Terraform architecture<\/span><\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">The source stage is simply used to connect the pipeline with the GitHub repository with the command <span style=\"background-color: #d9d9d9;\">CodeStarSourceConnection<\/span><\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><mark><i><span style=\"font-weight: 400;\">\ud83d\udcddNote: Remember, this command: CodeStarSourceConnection is only used when using the source code from GitHub, Bitbucket, and GitHub Enterprise Server.<\/span><\/i><\/mark><\/p>\n<p><span style=\"font-weight: 400;\">See the L126, where the <span style=\"background-color: #d9d9d9;\">build <\/span><\/span><span style=\"font-weight: 400;\">stage is mentioned with <span style=\"background-color: #d9d9d9;\">CodeBuild <\/span><\/span><span style=\"font-weight: 400;\">to build and deploy the app located in the <span style=\"background-color: #d9d9d9;\">aws_codebuild_project <\/span><\/span><span style=\"font-weight: 400;\">resource configuration file. You can even use a close alternative to this, which is &#8211; Custom Jenkins.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This <span style=\"background-color: #d9d9d9;\">source <\/span><\/span><span style=\"font-weight: 400;\">\u00a0phase also represents the output artifact in the form of an input artifact in the build stage.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">See lines 55-125 to check how CodePipeline roles and policies are created, which is important for its associated S3 bucket, CodeStar, IAM, KMS, and CodeBuild activities.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">See Lines 126-172 to create a <span style=\"background-color: #d9d9d9;\">CodeBuild<\/span><\/span><span style=\"font-weight: 400;\">\u00a0resource asking to use a Linux container to pass the environmental variables into the build, alongside the use of a buildspec file in the source block.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">See lines 173-247 where CodeBuild&#8217;s roles and policies are declared, which plays an important role in accessing the IAM, S3 bucket, ECR, and ECS.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Uff! \ud83d\ude2e\u200d\ud83d\udca8Finally the relief of explaining a bunch of configurations. Let&#8217;s move on to the application of our setup.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s directory tree checking time! \u231a<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image6.png\" alt=\"checking time\" width=\"1076\" height=\"300\" class=\"alignnone wp-image-5929 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image6.png 1076w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image6-300x84.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image6-1024x286.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image6-768x214.png 768w\" sizes=\"auto, (max-width: 1076px) 100vw, 1076px\" \/><\/p>\n<p><b>Now, let\u2019s apply the configuration with the use of Terraform:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Here\u2019s the command for it:<\/span><span style=\"font-weight: 400;\"> <span style=\"background-color: #d9d9d9;\">$ terraform apply<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image13.png\" alt=\"terraform apply\" width=\"1200\" height=\"787\" class=\"alignnone wp-image-5930 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image13.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image13-300x197.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image13-1024x672.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image13-768x504.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image42.png\" alt=\"apply\" width=\"1200\" height=\"793\" class=\"alignnone wp-image-5931 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image42.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image42-300x198.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image42-1024x677.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image42-768x508.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><b>Implementation Verification Time \u231a<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s begin with checking the CodePipeline!<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image33.png\" alt=\"CodePipeline\" width=\"1200\" height=\"776\" class=\"alignnone wp-image-5932 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image33.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image33-300x194.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image33-1024x662.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image33-768x497.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">There are times when the first attempt does fail, as we require to authenticate the GitHub connection. Hence, you&#8217;ll detect an error like this as shown below:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image44.png\" alt=\"flask demo Pipeline\" width=\"1200\" height=\"776\" class=\"alignnone wp-image-5933 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image44.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image44-300x194.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image44-1024x662.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image44-768x497.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, let&#8217;s Authorize the GitHub connection by following this path: Navigate to Settings&gt;Connections;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image26.png\" alt=\"setting\" width=\"1200\" height=\"776\" class=\"alignnone wp-image-5934 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image26.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image26-300x194.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image26-1024x662.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image26-768x497.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Once we\u2019ll update the GitHub connection request, we\u2019re all good to delve in:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19.png\" alt=\"flask demo \" width=\"1200\" height=\"586\" class=\"alignnone wp-image-5935 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-300x147.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1024x500.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-768x375.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image40.png\" alt=\"connect to github\" width=\"584\" height=\"548\" class=\"alignnone wp-image-5936 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image40.png 584w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image40-300x282.png 300w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">As we update the connection, the status will change into <span style=\"background-color: #d9d9d9;\">Available<\/span><\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1.png\" alt=\"update demo\" width=\"1200\" height=\"586\" class=\"alignnone wp-image-5937 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1-300x147.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1-1024x500.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image19-1-768x375.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, push the local Flask app source code to the GitHub repository and observe the pipeline stages and status;<\/span><\/p>\n<div>\n<pre>$ git status\r\n$ git add .\r\n$ git commit -m \"full setup\"\r\n$ git push origin main<\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">If triggering the pipeline at this moment, it will throw an error like this:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"background-color: #d9d9d9;\">[GitHub] Upload\u00a0to S3 failed with the following error: The ciphertext refers to a customer master key that does not exist, does not exist in this region, or you are not allowed to access.<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">The error indicates a missing link to the KMS key with the CodePipeline and CodeBuild roles. But worry not! It can be done right now as well \ud83d\ude0c:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now, open <span style=\"background-color: #d9d9d9;\">flask_app_s3kmskey<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image21.png\" alt=\"flask_app_s3kmskey\" width=\"1200\" height=\"365\" class=\"alignnone wp-image-5938 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image21.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image21-300x91.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image21-1024x311.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image21-768x234.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Scroll down a bit and now make the link as discussed above:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image28.png\" alt=\"discussed above\" width=\"1200\" height=\"562\" class=\"alignnone wp-image-5939 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image28.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image28-300x141.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image28-1024x480.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image28-768x360.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">To see the results, it\u2019ll ask for rerunning the Pipeline, which is not an issue \ud83e\udd13<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image35.png\" alt=\"rerunning the Pipeline\" width=\"1200\" height=\"551\" class=\"alignnone wp-image-5940 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image35.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image35-300x138.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image35-1024x470.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image35-768x353.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Open the <\/span><span style=\"font-weight: 400;\">AWS CodeBuild<\/span><span style=\"font-weight: 400;\"> to see some more information:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image39.png\" alt=\"CodeBuild\" width=\"1200\" height=\"551\" class=\"alignnone wp-image-5941 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image39.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image39-300x138.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image39-1024x470.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image39-768x353.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image45.png\" alt=\"CodeBuild\" width=\"1200\" height=\"617\" class=\"alignnone wp-image-5942 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image45.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image45-300x154.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image45-1024x527.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image45-768x395.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, click on the latest build run from the history to check some information regarding the same:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image25.png\" alt=\"information regarding\" width=\"1200\" height=\"617\" class=\"alignnone wp-image-5944 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image25.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image25-300x154.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image25-1024x527.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image25-768x395.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image4-1.png\" alt=\"flask demo\" width=\"1200\" height=\"617\" class=\"alignnone wp-image-5945 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image4-1.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image4-1-300x154.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image4-1-1024x527.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image4-1-768x395.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image37.png\" alt=\" regarding\" width=\"1200\" height=\"617\" class=\"alignnone wp-image-5975 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image37.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image37-300x154.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image37-1024x527.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image37-768x395.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, you know how to explore more information! The genius you! \ud83d\ude0e<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Shall we now move forward to the ECS verification? Let\u2019s go!<\/span><\/p>\n<p><b>ECS Verification<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Search for the ECS cluster, we just created to check the cluster information:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image27.png\" alt=\"ECS \" width=\"1200\" height=\"211\" class=\"alignnone wp-image-5946 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image27.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image27-300x53.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image27-1024x180.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image27-768x135.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image49.png\" alt=\"ECS Verification\" width=\"1200\" height=\"405\" class=\"alignnone wp-image-5947 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image49.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image49-300x101.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image49-1024x346.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image49-768x259.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image38.png\" alt=\"ECS Verification demo\" width=\"1200\" height=\"435\" class=\"alignnone wp-image-5948 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image38.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image38-300x109.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image38-1024x371.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image38-768x278.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, follow this path to check the networking configuration: <span style=\"background-color: #d9d9d9; font-weight: 900;\">Clusters &gt; Services &gt; flask-app-demo &gt; Networking<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image10.png\" alt=\"Networking\" width=\"1200\" height=\"507\" class=\"alignnone wp-image-5949 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image10.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image10-300x127.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image10-1024x433.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image10-768x324.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">When you see the load balancer URL, click on it, and voila, you can see your first Flask Application ready &#8211; AKA the deployed version of the app.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image30.png\" alt=\"version application\" width=\"1200\" height=\"567\" class=\"alignnone wp-image-5950 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image30.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image30-300x142.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image30-1024x484.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image30-768x363.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, moving on to the Continuous Deployment Verification process:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">At first, you&#8217;ll need to update the flask application: <span style=\"background-color: #d9d9d9;\">flask_app\/app.py<\/span><\/span><\/p>\n<div>\n<pre><code>from flask import Flask\r\napp = Flask(__name__)\r\n@app.route(\"\/\")\r\ndef hello():\r\n    return \"Yayy, we have the 2nd version of our flask application\"\r\nif __name__ == \"__main__\":\r\n    app.run(host=\"0.0.0.0\")\r\n<\/code><\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">Then push the application code to the GitHub, like this:<\/span><\/p>\n<div>\n<pre><code>$ git status\r\n$ git add .\r\n$ git commit -m \"update flask app\"\r\n$ git push origin main<\/code><\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\">There\u2019ll also a requirement to check the Pipeline &#8211; done like this:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image41.png\" alt=\"version demo\" width=\"1200\" height=\"461\" class=\"alignnone wp-image-5952 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image41.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image41-300x115.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image41-1024x393.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image41-768x295.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Once the build is done, you can check the information reflected on the app like this:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image1.png\" alt=\"flask demo\" width=\"1200\" height=\"461\" class=\"alignnone wp-image-5951 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image1.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image1-300x115.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image1-1024x393.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image1-768x295.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image29.png\" alt=\"demo\" width=\"1200\" height=\"497\" class=\"alignnone wp-image-5953 size-full\" srcset=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image29.png 1200w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image29-300x124.png 300w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image29-1024x424.png 1024w, https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/image29-768x318.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Woohoo! \ud83e\udd73 You&#8217;ve now excelled at deploying the application into the AWS ECS using AWS CodePipeline and Terraform!<\/span><\/p>\n<h3 style=\"color: #1c5f9b;\">Conclusion<\/h3>\n<p><span style=\"font-weight: 400;\">You&#8217;ve done a great job so far! However, you can optimize this process a bit by taking some suggestions, like this:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Automating the configuration by terraform gitlab with GitHub or GitLabCI;<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Finding out and experimenting with more AWS CodePipeline use cases (for example, how will you get approvals before deploying the app?);<\/span><\/li>\n<li style=\"font-weight: 400; list-style-type: disc;\" aria-level=\"1\">\n<p style=\"font-weight: 400;\">Finally, make the most out of AWS CodePipeline to deploy other AWS services, like Amazon EBS.<\/p>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Keep trying, keep experimenting, and keep striving for excellence! That&#8217;s what we promote at Tuvoc Technologies.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction We live in an era where everyone wants everything in no time. Well, in some cases, it can happen, but for some, it requires a set of principles to streamline the whole process to make it possible, not exactly, in no time but faster than the one traditional process. And when it comes to [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":5882,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[124],"tags":[],"class_list":["post-5881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-app-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deploy Critical Builds on Amazon ECS with Terraform<\/title>\n<meta name=\"description\" content=\"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploy Critical Builds on Amazon ECS with Terraform\" \/>\n<meta property=\"og:description\" content=\"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\" \/>\n<meta property=\"og:site_name\" content=\"Tuvoc Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tuvoctechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-28T10:00:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-15T12:53:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png\" \/>\n\t<meta property=\"og:image:width\" content=\"868\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Kishan Lashkari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Tuvocpvtltd\" \/>\n<meta name=\"twitter:site\" content=\"@Tuvocpvtltd\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kishan Lashkari\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"25 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\"},\"author\":{\"name\":\"Kishan Lashkari\",\"@id\":\"https:\/\/www.tuvoc.com\/#\/schema\/person\/a9df2f2c8d88eca0cbe849020df8e8d1\"},\"headline\":\"How to Deploy Your Mission-critical Builds in Amazon ECS Using AWS CodePipeline and Terraform?\",\"datePublished\":\"2023-03-28T10:00:19+00:00\",\"dateModified\":\"2024-11-15T12:53:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\"},\"wordCount\":3248,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tuvoc.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png\",\"articleSection\":[\"App Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\",\"url\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\",\"name\":\"Deploy Critical Builds on Amazon ECS with Terraform\",\"isPartOf\":{\"@id\":\"https:\/\/www.tuvoc.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png\",\"datePublished\":\"2023-03-28T10:00:19+00:00\",\"dateModified\":\"2024-11-15T12:53:44+00:00\",\"description\":\"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage\",\"url\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png\",\"contentUrl\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png\",\"width\":868,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.tuvoc.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Deploy Your Mission-critical Builds in Amazon ECS Using AWS CodePipeline and Terraform?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tuvoc.com\/#website\",\"url\":\"https:\/\/www.tuvoc.com\/\",\"name\":\"Tuvoc Technologies\",\"description\":\"Top Secure Web &amp; Mobile Application Development Company\",\"publisher\":{\"@id\":\"https:\/\/www.tuvoc.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.tuvoc.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tuvoc.com\/#organization\",\"name\":\"Tuvoc Technologies\",\"url\":\"https:\/\/www.tuvoc.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.tuvoc.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/07\/Tuvoc-1.svg\",\"contentUrl\":\"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/07\/Tuvoc-1.svg\",\"width\":1,\"height\":1,\"caption\":\"Tuvoc Technologies\"},\"image\":{\"@id\":\"https:\/\/www.tuvoc.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tuvoctechnologies\/\",\"https:\/\/x.com\/Tuvocpvtltd\",\"https:\/\/www.instagram.com\/tuvocpvtltd\/\",\"https:\/\/www.linkedin.com\/company\/tuvoc-technologies\/people\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tuvoc.com\/#\/schema\/person\/a9df2f2c8d88eca0cbe849020df8e8d1\",\"name\":\"Kishan Lashkari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.tuvoc.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28f6a8beb1410ad90d8584f9e2eafcf9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28f6a8beb1410ad90d8584f9e2eafcf9?s=96&d=mm&r=g\",\"caption\":\"Kishan Lashkari\"},\"url\":\"https:\/\/www.tuvoc.com\/author\/kishan_lashkari\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deploy Critical Builds on Amazon ECS with Terraform","description":"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/","og_locale":"en_US","og_type":"article","og_title":"Deploy Critical Builds on Amazon ECS with Terraform","og_description":"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.","og_url":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/","og_site_name":"Tuvoc Technologies","article_publisher":"https:\/\/www.facebook.com\/tuvoctechnologies\/","article_published_time":"2023-03-28T10:00:19+00:00","article_modified_time":"2024-11-15T12:53:44+00:00","og_image":[{"width":868,"height":540,"url":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png","type":"image\/png"}],"author":"Kishan Lashkari","twitter_card":"summary_large_image","twitter_creator":"@Tuvocpvtltd","twitter_site":"@Tuvocpvtltd","twitter_misc":{"Written by":"Kishan Lashkari","Est. reading time":"25 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#article","isPartOf":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/"},"author":{"name":"Kishan Lashkari","@id":"https:\/\/www.tuvoc.com\/#\/schema\/person\/a9df2f2c8d88eca0cbe849020df8e8d1"},"headline":"How to Deploy Your Mission-critical Builds in Amazon ECS Using AWS CodePipeline and Terraform?","datePublished":"2023-03-28T10:00:19+00:00","dateModified":"2024-11-15T12:53:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/"},"wordCount":3248,"commentCount":0,"publisher":{"@id":"https:\/\/www.tuvoc.com\/#organization"},"image":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage"},"thumbnailUrl":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png","articleSection":["App Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/","url":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/","name":"Deploy Critical Builds on Amazon ECS with Terraform","isPartOf":{"@id":"https:\/\/www.tuvoc.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage"},"image":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage"},"thumbnailUrl":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png","datePublished":"2023-03-28T10:00:19+00:00","dateModified":"2024-11-15T12:53:44+00:00","description":"Explore the process to deploy mission-critical builds in Amazon ECS using AWS CodePipeline and Terraform for efficient, automated deployment.","breadcrumb":{"@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#primaryimage","url":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png","contentUrl":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/03\/How-To-Use-AWS-CodePipeline-And-Terraform-To-Continuously-Deploy-Application-Into-Amazon-ECS.png","width":868,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/www.tuvoc.com\/blog\/how-to-deploy-your-mission-critical-builds-in-amazon-ecs-using-aws-codepipeline-and-terraform\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.tuvoc.com\/"},{"@type":"ListItem","position":2,"name":"How to Deploy Your Mission-critical Builds in Amazon ECS Using AWS CodePipeline and Terraform?"}]},{"@type":"WebSite","@id":"https:\/\/www.tuvoc.com\/#website","url":"https:\/\/www.tuvoc.com\/","name":"Tuvoc Technologies","description":"Top Secure Web &amp; Mobile Application Development Company","publisher":{"@id":"https:\/\/www.tuvoc.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tuvoc.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.tuvoc.com\/#organization","name":"Tuvoc Technologies","url":"https:\/\/www.tuvoc.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tuvoc.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/07\/Tuvoc-1.svg","contentUrl":"https:\/\/www.tuvoc.com\/wp-content\/uploads\/2023\/07\/Tuvoc-1.svg","width":1,"height":1,"caption":"Tuvoc Technologies"},"image":{"@id":"https:\/\/www.tuvoc.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tuvoctechnologies\/","https:\/\/x.com\/Tuvocpvtltd","https:\/\/www.instagram.com\/tuvocpvtltd\/","https:\/\/www.linkedin.com\/company\/tuvoc-technologies\/people\/"]},{"@type":"Person","@id":"https:\/\/www.tuvoc.com\/#\/schema\/person\/a9df2f2c8d88eca0cbe849020df8e8d1","name":"Kishan Lashkari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tuvoc.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28f6a8beb1410ad90d8584f9e2eafcf9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28f6a8beb1410ad90d8584f9e2eafcf9?s=96&d=mm&r=g","caption":"Kishan Lashkari"},"url":"https:\/\/www.tuvoc.com\/author\/kishan_lashkari\/"}]}},"_links":{"self":[{"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/posts\/5881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/comments?post=5881"}],"version-history":[{"count":0,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/posts\/5881\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/media\/5882"}],"wp:attachment":[{"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/media?parent=5881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/categories?post=5881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tuvoc.com\/wp-json\/wp\/v2\/tags?post=5881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}