{"id":22796374,"url":"https://github.com/atulkamble/webapp-cloudformation","last_synced_at":"2025-07-02T09:36:05.298Z","repository":{"id":264986291,"uuid":"862083690","full_name":"atulkamble/webapp-cloudformation","owner":"atulkamble","description":"This repository contains a CloudFormation template and step-by-step guide to launch and automate infrastructure for a web application on AWS. It includes resources like VPC, EC2 instances, Security Groups, and an Application Load Balancer. This setup is designed for hosting a simple web app with scalable infrastructure on the AWS Cloud.","archived":false,"fork":false,"pushed_at":"2025-05-18T09:24:18.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-25T23:37:07.445Z","etag":null,"topics":["automation","aws","cloudformation","loadbalancer","vpc","webapp"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atulkamble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-24T02:27:16.000Z","updated_at":"2025-05-18T09:24:21.000Z","dependencies_parsed_at":"2025-05-18T10:24:17.703Z","dependency_job_id":"0498b5f8-e07e-4f3d-a378-755af2abb3fc","html_url":"https://github.com/atulkamble/webapp-cloudformation","commit_stats":null,"previous_names":["atulkamble/webapp-cloudformation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atulkamble/webapp-cloudformation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fwebapp-cloudformation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fwebapp-cloudformation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fwebapp-cloudformation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fwebapp-cloudformation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulkamble","download_url":"https://codeload.github.com/atulkamble/webapp-cloudformation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fwebapp-cloudformation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263112431,"owners_count":23415616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","aws","cloudformation","loadbalancer","vpc","webapp"],"created_at":"2024-12-12T05:12:38.101Z","updated_at":"2025-07-02T09:36:05.268Z","avatar_url":"https://github.com/atulkamble.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# webapp-cloudformation\n\nTo launch the infrastructure for executing a web application using **AWS CloudFormation**, you'll need a **CloudFormation template** that automates the process of setting up a VPC, EC2 instances, a Load Balancer, and other resources. Below are the steps and an example CloudFormation template.\n\n### **Steps to Launch Infrastructure Using CloudFormation:**\n\n1. **Go to the AWS Management Console**:\n   - Navigate to the **CloudFormation** service in the AWS Management Console.\n\n2. **Create a New Stack**:\n   - Click on **Create Stack** and choose **\"With new resources (standard)\"**.\n   - You can either upload your template as a `.yaml` file or paste it directly into the editor.\n\n3. **Configure Stack Details**:\n   - Enter a **Stack Name** (e.g., `WebAppInfrastructure`).\n   - Provide any **parameters** required by the template (e.g., instance type, key pair name).\n\n4. **Review and Create**:\n   - Review the stack configuration, ensure the permissions are appropriate, and click **Create Stack**.\n   - Wait for CloudFormation to provision all the resources. You can monitor the process in the **Events** tab.\n\n5. **Access and Test Your Web Application**:\n   - Once the stack is created, access your web application using the **Load Balancer's DNS** or **Elastic IP**.\n   - CloudFormation will automatically create and link all required resources like EC2, Security Groups, VPC, and Load Balancer.\n\n---\n\n### **CloudFormation Template for a Simple Web Application**\n\nHere’s a basic **CloudFormation template** that launches a VPC, an EC2 instance in a public subnet, and an Application Load Balancer.\n\n```yaml\nAWSTemplateFormatVersion: \"2010-09-09\"\nDescription: \"CloudFormation Template to launch infrastructure for a web application.\"\n\nParameters:\n  InstanceType:\n    Description: \"EC2 Instance Type\"\n    Type: String\n    Default: t2.micro\n    AllowedValues:\n      - t2.micro\n      - t2.small\n      - t2.medium\n    ConstraintDescription: \"must be a valid EC2 instance type.\"\n  \n  KeyName:\n    Description: \"Name of an existing EC2 KeyPair to enable SSH access\"\n    Type: AWS::EC2::KeyPair::KeyName\n\nResources:\n  MyVPC:\n    Type: AWS::EC2::VPC\n    Properties:\n      CidrBlock: 10.0.0.0/16\n      EnableDnsSupport: true\n      EnableDnsHostnames: true\n      Tags:\n        - Key: Name\n          Value: MyVPC\n\n  MyInternetGateway:\n    Type: AWS::EC2::InternetGateway\n\n  AttachGateway:\n    Type: AWS::EC2::VPCGatewayAttachment\n    Properties:\n      VpcId: !Ref MyVPC\n      InternetGatewayId: !Ref MyInternetGateway\n\n  PublicSubnet:\n    Type: AWS::EC2::Subnet\n    Properties:\n      VpcId: !Ref MyVPC\n      CidrBlock: 10.0.1.0/24\n      MapPublicIpOnLaunch: true\n\n  MyRouteTable:\n    Type: AWS::EC2::RouteTable\n    Properties:\n      VpcId: !Ref MyVPC\n\n  PublicRoute:\n    Type: AWS::EC2::Route\n    Properties:\n      RouteTableId: !Ref MyRouteTable\n      DestinationCidrBlock: 0.0.0.0/0\n      GatewayId: !Ref MyInternetGateway\n\n  AssociateRouteTable:\n    Type: AWS::EC2::SubnetRouteTableAssociation\n    Properties:\n      SubnetId: !Ref PublicSubnet\n      RouteTableId: !Ref MyRouteTable\n\n  WebServerSecurityGroup:\n    Type: AWS::EC2::SecurityGroup\n    Properties:\n      GroupDescription: \"Allow HTTP and SSH traffic\"\n      VpcId: !Ref MyVPC\n      SecurityGroupIngress:\n        - IpProtocol: tcp\n          FromPort: 22\n          ToPort: 22\n          CidrIp: 0.0.0.0/0\n        - IpProtocol: tcp\n          FromPort: 80\n          ToPort: 80\n          CidrIp: 0.0.0.0/0\n\n  EC2Instance:\n    Type: AWS::EC2::Instance\n    Properties:\n      InstanceType: !Ref InstanceType\n      KeyName: !Ref KeyName\n      SecurityGroupIds:\n        - !Ref WebServerSecurityGroup\n      SubnetId: !Ref PublicSubnet\n      ImageId: ami-0ebfd941bbafe70c6  # Amazon Linux 2023 AMI\n      UserData:\n        Fn::Base64: |\n          #!/bin/bash\n          yum update -y\n          yum install -y httpd\n          systemctl start httpd\n          systemctl enable httpd\n          echo \"Hello World from $(hostname -f)\" \u003e /var/www/html/index.html\n\n  ApplicationLoadBalancer:\n    Type: AWS::ElasticLoadBalancingV2::LoadBalancer\n    Properties:\n      Name: WebAppLoadBalancer\n      Subnets:\n        - !Ref PublicSubnet\n      SecurityGroups:\n        - !Ref WebServerSecurityGroup\n\n  LoadBalancerListener:\n    Type: AWS::ElasticLoadBalancingV2::Listener\n    Properties:\n      LoadBalancerArn: !Ref ApplicationLoadBalancer\n      Protocol: HTTP\n      Port: 80\n      DefaultActions:\n        - Type: forward\n          TargetGroupArn: !Ref WebAppTargetGroup\n\n  WebAppTargetGroup:\n    Type: AWS::ElasticLoadBalancingV2::TargetGroup\n    Properties:\n      VpcId: !Ref MyVPC\n      Port: 80\n      Protocol: HTTP\n      TargetType: instance\n      HealthCheckProtocol: HTTP\n      HealthCheckPath: /\n      Matcher:\n        HttpCode: 200\n```\n\n### **Explanation of Key Sections**:\n1. **VPC and Networking**:\n   - **VPC** is created with a CIDR block of `10.0.0.0/16`.\n   - A **Public Subnet** with CIDR block `10.0.1.0/24` is provisioned.\n   - **Internet Gateway** and **Route Table** are set up to allow internet traffic.\n\n2. **Security Groups**:\n   - The **WebServerSecurityGroup** opens port 22 (SSH) and port 80 (HTTP) to the internet.\n\n3. **EC2 Instance**:\n   - **Amazon Linux 2023 AMI** is used to launch an instance.\n   - **UserData** is used to install and start **Apache HTTP Server** (`httpd`), making the instance a simple web server.\n\n4. **Application Load Balancer**:\n   - An **Application Load Balancer** (ALB) is created to distribute traffic across EC2 instances.\n   - A **Listener** is set up for port 80 to forward traffic to the web server.\n\n5. **Auto Scaling Group (Optional)**:\n   - You can add an Auto Scaling Group with rules to automatically scale EC2 instances based on traffic or resource usage.\n\n---\n\nThis template sets up a basic web application infrastructure on AWS. Let me know if you need further customization or additional services like databases or Auto Scaling.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fwebapp-cloudformation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkamble%2Fwebapp-cloudformation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fwebapp-cloudformation/lists"}