I have an existing Elastic Beanstalk application "app-ebs" and environment "App-ebs-env". I want to create a new application version in elastic beanstalk and deploy the newly created version using cloud formation(I do it manually for now).
The below code works for creating the new application version.(Only for the first time. If I try to update the stack and try the same template again, it does not work because there's no change set.)
Resources:
myAppVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName: app-ebs
SourceBundle:
S3Bucket: my-bucket-name
S3Key: sample.war
If I use AWS::ElasticBeanstalk::Environment, I get error because the environment already exists. I do not want to create a new environment.
Resources:
myAppVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName: app-ebs
SourceBundle:
S3Bucket: my-bucket-name
S3Key: sample.war
myEnvironment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: app-ebs
EnvironmentName: App-ebs-env
VersionLabel: !Ref myAppVersion # Reference the application version created above
SolutionStackName: 64bit Amazon Linux 2 v4.3.12 running Tomcat 8.5 Corretto 8
Any help would be appreciated!!
You have to import your AWS::ElasticBeanstalk::Environment
into CloudFormation first, before you can modify it from CloudFormation.
You have to do it for all resources that you created manually, and which you want to manage now using CloudFormation.