From a8c7fb0a061c9024c57ff1246cd2343f98b6189a Mon Sep 17 00:00:00 2001 From: David Harris Date: Thu, 31 Mar 2016 17:28:02 -0600 Subject: [PATCH] Adds `wait_for_ready_timeout` option to `aws_elastic_beanstalk_environment`. --- ...ource_aws_elastic_beanstalk_environment.go | 33 +++++++++++++++++-- ...lastic_beanstalk_environment.html.markdown | 28 ++++++++-------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elastic_beanstalk_environment.go b/builtin/providers/aws/resource_aws_elastic_beanstalk_environment.go index d7cfaed303f7..022eb578c4d5 100644 --- a/builtin/providers/aws/resource_aws_elastic_beanstalk_environment.go +++ b/builtin/providers/aws/resource_aws_elastic_beanstalk_environment.go @@ -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(), }, @@ -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 @@ -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, } @@ -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 @@ -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, } diff --git a/website/source/docs/providers/aws/r/elastic_beanstalk_environment.html.markdown b/website/source/docs/providers/aws/r/elastic_beanstalk_environment.html.markdown index 8b842f954d89..6c37d071fa2c 100644 --- a/website/source/docs/providers/aws/r/elastic_beanstalk_environment.html.markdown +++ b/website/source/docs/providers/aws/r/elastic_beanstalk_environment.html.markdown @@ -8,11 +8,11 @@ description: |- # aws\_elastic\_beanstalk\_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 @@ -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 @@ -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 @@ -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 - -