AWS CloudFormation Template- Elastic Beanstalk application

AWS CloudFormation Template- Elastic Beanstalk application

Introduction :-

AWS CloudFormation template defines a set of AWS resources that are essential for deploying an application on #AWS Elastic Beanstalk. Elastic Beanstalk is a #Platform as a Service (PaaS) offered by #Amazon Web Services that simplifies the deployment, scaling, and management of web applications. This template specifies the resources required for an application and includes an IAM instance profile, an Elastic Beanstalk application, an application version, and a configuration template. These resources collectively form the infrastructure needed to run the application in a Docker container.

Deployment Steps

Follow these steps to upload and create the CloudFormation stack using the #AWS Management Console:

  1. Sign in to the AWS Management Console: Log in to your AWS account if you haven’t already.

2. Navigate to CloudFormation: Go to the #AWS CloudFormation service from the #AWS Management Console.

3. Click the “Create stack” button.

4. Upload the CloudFormation template file (YAML).

Yaml :

AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template for Elastic Beanstalk Application

Resources:
  FamilyPortalBackendInstanceProfile:
    Type: 'AWS::IAM::InstanceProfile'
    Properties:
      Path: /
      Roles:
  FamilyPortalBackendApplication:
    Type: 'AWS::ElasticBeanstalk::Application'
    Properties:
      ApplicationName: !Sub '${EnvironmentName}-${ApplicationName}'

  FamilyPortalBackendApplicationVersion:
    Type: 'AWS::ElasticBeanstalk::ApplicationVersion'
    Properties:
      Description: !Join
        - ' '
        - - Environment
          - !Ref EnvironmentName
      ApplicationName: BackendApplication
      SourceBundle:
        S3Bucket: !Ref BeanstalkDockerBundleBucketName
        S3Key: !Ref BeanstalkDockerBundleObjectKey

  FamilyPortalBackendConfigurationTemplate:
    Type: 'AWS::ElasticBeanstalk::ConfigurationTemplate'
    Properties:
      ApplicationName: !Ref BackendApplication
      OptionSettings:
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: InstanceType
          Value: !Ref Ec2InstanceType
        - Namespace: 'aws:ec2:vpc'
          OptionName: VPCId
          Value: !ImportValue
            'Fn::Sub': '${NetworkStackName}-VpcId'
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: IamInstanceProfile
          Value: !Ref FamilyPortalBackendInstanceProfile
        - Namespace: 'aws:ec2:vpc'
          OptionName: Subnets
          Value: !Join
            - ','
            - - !ImportValue
                'Fn::Sub': '${NetworkStackName}-PrivateSubnet1Id'
              - !ImportValue
                'Fn::Sub': '${NetworkStackName}-PrivateSubnet2Id'

5. Specify Stack Details:

  • Enter a Stack name for your deployment.

  • Provide parameter values as needed.

  • Review and acknowledge the capabilities .

  • You can set additional stack options or tags if necessary.

6. Review and Create:

  • Review the stack details and configuration.

  • Click “Create stack” to initiate the deployment.

7. Monitor Stack Creation:

  • The CloudFormation stack creation process will begin.

  • Monitor the stack events in the #AWS Management Console.

Conclusion :-

CloudFormation template streamlines the process of provisioning and configuring the infrastructure necessary for deploying the application on #AWS Elastic Beanstalk. The template sets up the #IAM instance profile for instances, defines the Elastic Beanstalk application, its associated version, and the configuration settings. By using this template, you can easily and consistently deploy your application, manage its resources, and ensure that it runs in a secure and scalable environment on AWS. This template can serve as a foundational building block for creating robust and automated #AWS deployments.