Git Product home page Git Product logo

devops-task's Introduction

Overview

This documentation provides instructions on how to deploy a CloudFormation stack for a containerized web application on AWS ECS Fargate. The template sets up a VPC, subnets, an ECS cluster, an Application Load Balancer (ALB), and necessary roles and security groups.

Application Description

The web application is a basic clicker app, consisting of the following files:

  • Dockerfile: Defines the Docker container configuration.
  • index.html: The front-end HTML file for the web application.
  • app.js: The Node.js script that handles the click event and logs it to AWS CloudWatch.

These files are provided for reference. The actual Docker image used by the CloudFormation stack is pre-built and hosted on Docker Hub.

Stack Features

  • Virtual Private Cloud (VPC): Creates an isolated network environment.
  • Subnets: Configures public and private subnets within the VPC.
  • Internet Gateway: Connects the VPC to the internet.
  • ECS Cluster: Hosts the ECS Fargate services and tasks.
  • ECS Fargate Service and Task: Manages and runs the containerized application.
  • Application Load Balancer (ALB): Distributes incoming web traffic across multiple targets, such as ECS tasks, in multiple Availability Zones.
  • Auto Scaling: Automatically adjusts the number of ECS tasks based on the load.
  • Security Groups: Controls inbound and outbound traffic to the ECS service and ALB.
  • Network ACLs: Additional layer of security that acts as a firewall for controlling traffic in and out of the subnets.
  • IAM Roles: Provides necessary permissions for ECS tasks and Auto Scaling.
  • CloudWatch Log Group: Collects logs from the ECS tasks.
  • SNS Topic: For sending notifications, such as CloudWatch Alarm alerts.

Prerequisites

  • AWS Account: You must have an AWS account with appropriate permissions to create AWS resources like VPC, ECS, IAM roles, etc.
  • Docker Image: The Docker image for the web application should be available in a registry (e.g., Amazon ECR or Docker Hub).

Customization

Before deployment, you can customize the following parameters in the CloudFormation template:

  • VpcCidr: CIDR block for the VPC.
  • PublicSubnet1Cidr, PublicSubnet2Cidr: CIDR blocks for public subnets.
  • PrivateSubnet1Cidr, PrivateSubnet2Cidr: CIDR blocks for private subnets.
  • TaskCpu, TaskMemory: CPU and memory allocation for ECS tasks.
  • MaxAutoScalingCapacity, MinAutoScalingCapacity: Auto-scaling parameters for ECS service.
  • DockerImage: Docker image URL for the ECS task.

Deployment Steps

Deploying via AWS CLI

  1. Prepare the CloudFormation Template:

    • Download or clone the CloudFormation template to your local machine.
    • Make any necessary customizations as per your requirements.
  2. Deploy the CloudFormation Stack:

    • Open a terminal or command prompt.
    • Navigate to the directory containing the CloudFormation template.
    • Use the AWS CLI to deploy the stack. Replace my-stack-name with your desired stack name:
      aws cloudformation create-stack --stack-name my-stack-name --template-body file://path_to_template/template.yaml --parameters ParameterKey=VpcCidr,ParameterValue=10.0.0.0/16 ParameterKey=PublicSubnet1Cidr,ParameterValue=10.0.1.0/24 # ... other parameters ...
      
    • Wait for the stack to be created. This may take several minutes.

Deploying via AWS Management Console

  1. Log in to AWS Management Console:

    • Open the AWS Management Console in your web browser and log in to your account.
  2. Open the CloudFormation Service:

    • Navigate to the CloudFormation service.
  3. Create a New Stack:

    • Click on "Create Stack" and select "With new resources (standard)".
    • Choose "Upload a template file", then click "Choose file" and upload your CloudFormation template.
    • Click "Next".
  4. Specify Stack Details:

    • Enter a Stack name.
    • Fill in the parameters as required (e.g., VPC CIDR, Subnet CIDRs, Docker image).
    • Click "Next".
  5. Configure Stack Options (Optional):

    • Configure additional options as needed (tags, permissions, etc.).
    • Click "Next".
  6. Review and Create Stack:

    • Review the stack configuration.
    • Acknowledge that AWS CloudFormation might create IAM resources.
    • Click "Create stack".
  7. Monitor Stack Creation:

    • Wait for the stack to be created. You can monitor the progress in the "Events" tab.

Using the Application

Once the CloudFormation stack is successfully deployed, you can use the web application by following these steps:

Access the Application

  • Open the AWS Management Console.
  • Navigate to the EC2 service and select "Load Balancers" from the navigation pane.
  • Find the Load Balancer created by your CloudFormation stack (its name will be part of the stack's output).
  • Copy the DNS name of the Load Balancer and paste it into your web browser's address bar.

Interacting with the Application

  • Once the application loads, you should see a simple web interface with a "Click" button.
  • Click the "Click" button. This action will trigger an event in the application, which is logged to AWS CloudWatch.

Viewing Logs in CloudWatch

  • To view the logs generated by your clicks, navigate to the CloudWatch service in the AWS Management Console.
  • In the CloudWatch dashboard, select "Logs" from the navigation pane.
  • Find the Log Group named /ecs/devops-task (as specified in your CloudFormation template).
  • Click on the Log Group to view the log streams.
  • Select a log stream to view the detailed logs of the application interactions.

Updating and Deleting the Stack

  • To update the stack, you can either modify the template and repeat the deployment process or use the AWS Management Console to update specific parameters.
  • To delete the stack, go to the CloudFormation service in the AWS Management Console, select the stack, and choose "Delete".

devops-task's People

Contributors

fstepgv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.