Skip to content

Resource: awsElasticBeanstalkEnvironment

Provides an Elastic Beanstalk Environment Resource. Elastic Beanstalk allows you to deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs those applications.

Environments are often things such as development, integration, or production.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsElasticBeanstalkApplicationTftest =
  new aws.elasticBeanstalkApplication.ElasticBeanstalkApplication(
    this,
    "tftest",
    {
      description: "tf-test-desc",
      name: "tf-test-name",
    }
  );
new aws.elasticBeanstalkEnvironment.ElasticBeanstalkEnvironment(
  this,
  "tfenvtest",
  {
    application: awsElasticBeanstalkApplicationTftest.name,
    name: "tf-test-name",
    solutionStackName: "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4",
  }
);

Argument Reference

The following arguments are supported:

  • name - (Required) A unique name for this Environment. This name is used in the application URL
  • application – (Required) Name of the application that contains the version to be deployed
  • cnamePrefix - (Optional) Prefix to use for the fully qualified DNS name of the Environment.
  • description - (Optional) Short description of the Environment
  • tier - (Optional) Elastic Beanstalk Environment tier. Valid values are worker or webServer. If tier is left blank webServer will be used.
  • setting – (Optional) Option settings to configure the new Environment. These override specific values that are set as defaults. The format is detailed below in Option Settings
  • solutionStackName – (Optional) A solution stack to base your environment off of. Example stacks can be found in the Amazon API documentation
  • templateName – (Optional) The name of the Elastic Beanstalk Configuration template to use in deployment
  • platformArn – (Optional) The ARN of the Elastic Beanstalk Platform to use in deployment
  • waitForReadyTimeout - (Default 20M) The maximum duration that Terraform should wait for an Elastic Beanstalk Environment to be in a ready state before timing out.
  • pollInterval – The time between polling the AWS API to check if changes have been applied. Use this to adjust the rate of API calls for any create or update action. Minimum 10S, maximum 180S. Omit this to use the default behavior, which is an exponential backoff
  • versionLabel - (Optional) The name of the Elastic Beanstalk Application Version to use in deployment.
  • tags - (Optional) A set of tags to apply to the Environment. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Option Settings

Some options can be stack-specific, check AWS Docs for supported options and examples.

The setting and allSettings mappings support the following format:

  • namespace - unique namespace identifying the option's associated AWS resource
  • name - name of the configuration option
  • value - value for the configuration option
  • resource - (Optional) resource name for scheduled action

Example With Options

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsElasticBeanstalkApplicationTftest =
  new aws.elasticBeanstalkApplication.ElasticBeanstalkApplication(
    this,
    "tftest",
    {
      description: "tf-test-desc",
      name: "tf-test-name",
    }
  );
new aws.elasticBeanstalkEnvironment.ElasticBeanstalkEnvironment(
  this,
  "tfenvtest",
  {
    application: awsElasticBeanstalkApplicationTftest.name,
    name: "tf-test-name",
    setting: [
      {
        name: "VPCId",
        namespace: "aws:ec2:vpc",
        value: "vpc-xxxxxxxx",
      },
      {
        name: "Subnets",
        namespace: "aws:ec2:vpc",
        value: "subnet-xxxxxxxx",
      },
    ],
    solutionStackName: "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4",
  }
);

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - ID of the Elastic Beanstalk Environment.
  • name - Name of the Elastic Beanstalk Environment.
  • description - Description of the Elastic Beanstalk Environment.
  • tier - The environment tier specified.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
  • application – The Elastic Beanstalk Application specified for this environment.
  • setting – Settings specifically set for this Environment.
  • allSettings – List of all option settings configured in this Environment. These are a combination of default settings and their overrides from setting in the configuration.
  • cname - Fully qualified DNS name for this Environment.
  • autoscalingGroups - The autoscaling groups used by this Environment.
  • instances - Instances used by this Environment.
  • launchConfigurations - Launch configurations in use by this Environment.
  • loadBalancers - Elastic load balancers in use by this Environment.
  • queues - SQS queues in use by this Environment.
  • triggers - Autoscaling triggers in use by this Environment.
  • endpointUrl - The URL to the Load Balancer for this Environment

Import

Elastic Beanstalk Environments can be imported using the id, e.g.,

$ terraform import aws_elastic_beanstalk_environment.prodenv e-rpqsewtp2j