Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds wait_for_ready_timeout option to aws_elastic_beanstalk_environment. #5967

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ func resourceAwsElasticBeanstalkEnvironment() *schema.Resource {
Optional: true,
ConflictsWith: []string{"solution_stack_name"},
},
"wait_for_ready_timeout": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "10m",
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
duration, err := time.ParseDuration(value)
if err != nil {
errors = append(errors, fmt.Errorf(
"%q cannot be parsed as a duration: %s", k, err))
}
if duration < 0 {
errors = append(errors, fmt.Errorf(
"%q must be greater than zero", k))
}
return
},
},

"tags": tagsSchema(),
},
Expand All @@ -116,6 +134,10 @@ func resourceAwsElasticBeanstalkEnvironmentCreate(d *schema.ResourceData, meta i
settings := d.Get("setting").(*schema.Set)
solutionStack := d.Get("solution_stack_name").(string)
templateName := d.Get("template_name").(string)
waitForReadyTimeOut, err := time.ParseDuration(d.Get("wait_for_ready_timeout").(string))
if err != nil {
return err
}

// TODO set tags
// Note: at time of writing, you cannot view or edit Tags after creation
Expand Down Expand Up @@ -172,7 +194,7 @@ func resourceAwsElasticBeanstalkEnvironmentCreate(d *schema.ResourceData, meta i
Pending: []string{"Launching", "Updating"},
Target: []string{"Ready"},
Refresh: environmentStateRefreshFunc(conn, d.Id()),
Timeout: 10 * time.Minute,
Timeout: waitForReadyTimeOut,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -414,13 +436,18 @@ func resourceAwsElasticBeanstalkEnvironmentSettingsRead(d *schema.ResourceData,
func resourceAwsElasticBeanstalkEnvironmentDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn

waitForReadyTimeOut, err := time.ParseDuration(d.Get("wait_for_ready_timeout").(string))
if err != nil {
return err
}

opts := elasticbeanstalk.TerminateEnvironmentInput{
EnvironmentId: aws.String(d.Id()),
TerminateResources: aws.Bool(true),
}

log.Printf("[DEBUG] Elastic Beanstalk Environment terminate opts: %s", opts)
_, err := conn.TerminateEnvironment(&opts)
_, err = conn.TerminateEnvironment(&opts)

if err != nil {
return err
Expand All @@ -430,7 +457,7 @@ func resourceAwsElasticBeanstalkEnvironmentDelete(d *schema.ResourceData, meta i
Pending: []string{"Terminating"},
Target: []string{"Terminated"},
Refresh: environmentStateRefreshFunc(conn, d.Id()),
Timeout: 10 * time.Minute,
Timeout: waitForReadyTimeOut,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ description: |-

# aws\_elastic\_beanstalk\_<wbr>environment

Provides an Elastic Beanstalk Environment Resource. Elastic Beanstalk allows
you to deploy and manage applications in the AWS cloud without worrying about
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
Environments are often things such as `development`, `integration`, or
`production`.

## Example Usage
Expand All @@ -35,20 +35,24 @@ resource "aws_elastic_beanstalk_environment" "tfenvtest" {

The following arguments are supported:

* `name` - (Required) A unique name for this Environment. This name is used
* `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
* `application` – (Required) Name of the application that contains the version
to be deployed
* `description` - (Optional) Short description of the Environment
* `tier` - (Optional) Elastic Beanstalk Environment tier. Valid values are `Worker`
* `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](#option-settings)
* `solution_stack_name` – (Optional) A solution stack to base your environment
off of. Example stacks can be found in the [Amazon API documentation][1]
* `template_name` – (Optional) The name of the Elastic Beanstalk Configuration
* `template_name` – (Optional) The name of the Elastic Beanstalk Configuration
template to use in deployment
* `wait_for_ready_timeout` - (Default: "10m") The maximum
[duration](https://golang.org/pkg/time/#ParseDuration) that Terraform should
wait for an Elastic Beanstalk Environment to be in a ready state before timing
out.
* `tags` – (Optional) A set of tags to apply to the Environment. **Note:** at
this time the Elastic Beanstalk API does not provide a programatic way of
changing these tags after initial application
Expand All @@ -59,7 +63,7 @@ changing these tags after initial application

The `setting` and `all_settings` mappings support the following format:

* `namespace` - (Optional) unique namespace identifying the option's
* `namespace` - (Optional) unique namespace identifying the option's
associated AWS resource
* `name` - (Optional) name of the configuration option
* `value` - (Optional) value for the configuration option
Expand All @@ -70,14 +74,12 @@ The following attributes are exported:

* `name`
* `description`
* `tier` - the environment tier specified.
* `tier` - the environment tier specified.
* `application` – the application specified
* `setting` – Settings specifically set for this Environment
* `all_settings` – List of all option settings configured in the Environment. These
are a combination of default settings and their overrides from `settings` in
the configuration
the configuration


[1]: http://docs.aws.amazon.com/fr_fr/elasticbeanstalk/latest/dg/concepts.platforms.html