DEV Community

Mohan Sharma
Mohan Sharma

Posted on

Creating AWS Elastic Beanstalk Env through CLI commands


## CREATE APPLICATION VERSION

aws elasticbeanstalk create-application-version \
--application-name my-app-test \
--version-label v1 \
--source-bundle S3Bucket=test-bucket-apse1,S3Key=python-app.zip

## CREATE CONFIGURATION TEMPLATE 
aws elasticbeanstalk create-configuration-template \
--application-name my-app-test \
--template-name v1 \
--solution-stack-name "64bit Amazon Linux 2023 v4.7.1 running Python 3.13"

## CREATE ENVIRONMENT
aws elasticbeanstalk create-environment \
--cname-prefix my-cname \
--application-name my-app-test \
--version-label v1 \
--template-name v1 \
--environment-name v1clone2 \
--option-settings file://c:/MohanS/NPPFiles/Options.txt \
--tags Key=Key1,Value=hr Key=Env,Value=dev Key=Key2,Value=Key2Value –debug

## TERMINATE Environment
aws elasticbeanstalk terminate-environment --environment-name v1clone1

Enter fullscreen mode Exit fullscreen mode

OPTIONS.TXT FILE

[
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "IamInstanceProfile",
        "Value": "aws-elasticbeanstalk-ec2-role"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "InstanceType",
        "Value": "t3.xlarge"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "ImageId",
        "Value": "ami-0f77922ee968e2ec"
    },
    {
        "Namespace": "aws:elasticbeanstalk:environment",
        "OptionName": "ServiceRole",
        "Value": "servicerole-beanstalk"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "LaunchTemplateTagPropagationEnabled",
        "Value": "true"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "DisableIMDSv1",
        "Value": "true"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "RootVolumeType",
        "Value": "gp3"
    },
    {
        "Namespace": "aws:autoscaling:launchconfiguration",
        "OptionName": "RootVolumeSize",
        "Value": "64"
    },
    {
        "Namespace": "aws:ec2:vpc",
        "OptionName": "VPCId",
        "Value": "vpc-12345c5c68c0e840"
    },
    {
        "Namespace": "aws:ec2:vpc",
        "OptionName": "Subnets",
        "Value": "subnet-123456275dcb5,subnet-789012c147184c9"
    },
    {
        "Namespace": "aws:ec2:vpc",
        "OptionName": "ELBSubnets",
        "Value": "subnet-123456275dcb5,subnet-789012c147184c9"
    },
    {
        "Namespace": "aws:ec2:vpc",
        "OptionName": "ELBScheme",
        "Value": "internal"
    },
    {
        "Namespace": "aws:ec2:vpc",
        "OptionName": "AssociatePublicIpAddress",
        "Value": "false"
    }

]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)