How to create Elastic Beanstalk instance from s3 bucket in the aws-sdk?

Viewed 66

I am trying to deploy an elastic beanstalk instance from the aws javascript sdk and want the code source to come from an s3 bucket. I can see you can do this via the web interface but can't figure it out via the sdk.

so far I have the following which creates a new environment (application already exists at this point) but the env has no source code to run.

const elasticBeanstalkClient = new ElasticBeanstalkClient({ 
  region: "eu-west-2",
  credentials: {
    accessKeyId: awsAccessKeyId,
    secretAccessKey: awsAccessKeySecret
  } 
});

const createEnvironmentCommand = new CreateEnvironmentCommand({
  ApplicationName: applicationName,
  EnvironmentName: environmentName,
  SolutionStackName: "64bit Amazon Linux 2 v5.4.2 running Node.js 14",
  VersionLabel: versionLabel
})

return elasticBeanstalkClient.send(createEnvironmentCommand);

CreateEnvironmentCommand doesn't seem to have a source value that I can see. How am I supposed to tell the environment to be created from an s3 source?

1 Answers

I can see you can do this via the web interface but can't figure it out via the sdk.

EB console does a lot of things in the background to make it seem you can do it. With CDK you have to do everything by yourself. This means you have to createApplicationVersion first. When you do this, you can specify S3 location.

Related