Merge pull request #5915 from dharrisio/f-aws-elastic-beanstalk-environment-options
provider/aws: Adding outputs for elastic_beanstalk_environment resource.
This commit is contained in:
commit
4c2738ae98
|
@ -126,16 +126,10 @@ resource "aws_elastic_beanstalk_application" "tftest" {
|
|||
description = "tf-test-desc"
|
||||
}
|
||||
|
||||
#resource "aws_elastic_beanstalk_environment" "tfenvtest" {
|
||||
# name = "tf-test-name"
|
||||
# application = "${aws_elastic_beanstalk_application.tftest.name}"
|
||||
# solution_stack_name = "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4"
|
||||
#}
|
||||
|
||||
resource "aws_elastic_beanstalk_configuration_template" "tf_template" {
|
||||
name = "tf-test-template-config"
|
||||
application = "${aws_elastic_beanstalk_application.tftest.name}"
|
||||
solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.8 running Go 1.4"
|
||||
solution_stack_name = "64bit Amazon Linux running Python"
|
||||
}
|
||||
`
|
||||
|
||||
|
@ -167,7 +161,7 @@ resource "aws_elastic_beanstalk_configuration_template" "tf_template" {
|
|||
name = "tf-test-%s"
|
||||
application = "${aws_elastic_beanstalk_application.tftest.name}"
|
||||
|
||||
solution_stack_name = "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4"
|
||||
solution_stack_name = "64bit Amazon Linux running Python"
|
||||
|
||||
setting {
|
||||
namespace = "aws:ec2:vpc"
|
||||
|
|
|
@ -124,6 +124,36 @@ func resourceAwsElasticBeanstalkEnvironment() *schema.Resource {
|
|||
return
|
||||
},
|
||||
},
|
||||
"autoscaling_groups": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"instances": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"launch_configurations": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"load_balancers": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"queues": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"triggers": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
|
||||
"tags": tagsSchema(),
|
||||
},
|
||||
|
@ -342,6 +372,14 @@ func resourceAwsElasticBeanstalkEnvironmentRead(d *schema.ResourceData, meta int
|
|||
return nil
|
||||
}
|
||||
|
||||
resources, err := conn.DescribeEnvironmentResources(&elasticbeanstalk.DescribeEnvironmentResourcesInput{
|
||||
EnvironmentId: aws.String(envId),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := d.Set("description", env.Description); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -366,6 +404,26 @@ func resourceAwsElasticBeanstalkEnvironmentRead(d *schema.ResourceData, meta int
|
|||
}
|
||||
}
|
||||
|
||||
if err := d.Set("autoscaling_groups", flattenBeanstalkAsg(resources.EnvironmentResources.AutoScalingGroups)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := d.Set("instances", flattenBeanstalkInstances(resources.EnvironmentResources.Instances)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("launch_configurations", flattenBeanstalkLc(resources.EnvironmentResources.LaunchConfigurations)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("load_balancers", flattenBeanstalkElb(resources.EnvironmentResources.LoadBalancers)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("queues", flattenBeanstalkSqs(resources.EnvironmentResources.Queues)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("triggers", flattenBeanstalkTrigger(resources.EnvironmentResources.Triggers)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return resourceAwsElasticBeanstalkEnvironmentSettingsRead(d, meta)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ func TestAccAWSBeanstalkEnv_basic(t *testing.T) {
|
|||
|
||||
func TestAccAWSBeanstalkEnv_tier(t *testing.T) {
|
||||
var app elasticbeanstalk.EnvironmentDescription
|
||||
beanstalkQueuesNameRegexp := regexp.MustCompile("https://sqs.+?awseb[^,]+")
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -44,6 +45,38 @@ func TestAccAWSBeanstalkEnv_tier(t *testing.T) {
|
|||
Config: testAccBeanstalkWorkerEnvConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckBeanstalkEnvTier("aws_elastic_beanstalk_environment.tfenvtest", &app),
|
||||
resource.TestMatchResourceAttr(
|
||||
"aws_elastic_beanstalk_environment.tfenvtest", "queues.0", beanstalkQueuesNameRegexp),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSBeanstalkEnv_outputs(t *testing.T) {
|
||||
var app elasticbeanstalk.EnvironmentDescription
|
||||
beanstalkAsgNameRegexp := regexp.MustCompile("awseb.+?AutoScalingGroup[^,]+")
|
||||
beanstalkElbNameRegexp := regexp.MustCompile("awseb.+?EBLoa[^,]+")
|
||||
beanstalkInstancesNameRegexp := regexp.MustCompile("i-([0-9a-fA-F]{8}|[0-9a-fA-F]{17})")
|
||||
beanstalkLcNameRegexp := regexp.MustCompile("awseb.+?AutoScalingLaunch[^,]+")
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckBeanstalkEnvDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccBeanstalkEnvConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckBeanstalkEnvExists("aws_elastic_beanstalk_environment.tfenvtest", &app),
|
||||
resource.TestMatchResourceAttr(
|
||||
"aws_elastic_beanstalk_environment.tfenvtest", "autoscaling_groups.0", beanstalkAsgNameRegexp),
|
||||
resource.TestMatchResourceAttr(
|
||||
"aws_elastic_beanstalk_environment.tfenvtest", "load_balancers.0", beanstalkElbNameRegexp),
|
||||
resource.TestMatchResourceAttr(
|
||||
"aws_elastic_beanstalk_environment.tfenvtest", "instances.0", beanstalkInstancesNameRegexp),
|
||||
resource.TestMatchResourceAttr(
|
||||
"aws_elastic_beanstalk_environment.tfenvtest", "launch_configurations.0", beanstalkLcNameRegexp),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
|
||||
elasticsearch "github.com/aws/aws-sdk-go/service/elasticsearchservice"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/service/lambda"
|
||||
|
@ -1016,3 +1017,63 @@ func flattenCloudWachLogMetricTransformations(ts []*cloudwatchlogs.MetricTransfo
|
|||
|
||||
return m
|
||||
}
|
||||
|
||||
func flattenBeanstalkAsg(list []*elasticbeanstalk.AutoScalingGroup) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.Name != nil {
|
||||
strs = append(strs, *r.Name)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
||||
func flattenBeanstalkInstances(list []*elasticbeanstalk.Instance) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.Id != nil {
|
||||
strs = append(strs, *r.Id)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
||||
func flattenBeanstalkLc(list []*elasticbeanstalk.LaunchConfiguration) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.Name != nil {
|
||||
strs = append(strs, *r.Name)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
||||
func flattenBeanstalkElb(list []*elasticbeanstalk.LoadBalancer) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.Name != nil {
|
||||
strs = append(strs, *r.Name)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
||||
func flattenBeanstalkSqs(list []*elasticbeanstalk.Queue) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.URL != nil {
|
||||
strs = append(strs, *r.URL)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
||||
func flattenBeanstalkTrigger(list []*elasticbeanstalk.Trigger) []string {
|
||||
strs := make([]string, 0, len(list))
|
||||
for _, r := range list {
|
||||
if r.Name != nil {
|
||||
strs = append(strs, *r.Name)
|
||||
}
|
||||
}
|
||||
return strs
|
||||
}
|
||||
|
|
|
@ -74,15 +74,22 @@ The `setting` and `all_settings` mappings support the following format:
|
|||
|
||||
The following attributes are exported:
|
||||
|
||||
* `name`
|
||||
* `description`
|
||||
* `tier` - the environment tier specified.
|
||||
* `application` – the application specified
|
||||
* `setting` – Settings specifically set for this Environment
|
||||
* `name` - Name of the Elastic Beanstalk Environment.
|
||||
* `description` - Description of the Elastic Beanstalk Environment.
|
||||
* `tier` - The environment tier specified.
|
||||
* `application` – The Elastic Beanstalk Application specified for this environment.
|
||||
* `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.
|
||||
* `cname` - Fully qualified DNS name for the Environment.
|
||||
* `autoscaling_groups` - The autoscaling groups used by this environment.
|
||||
* `instances` - Instances used by this environment.
|
||||
* `launch_configurations` - Launch configurations in use by this environment.
|
||||
* `load_balancers` - Elastic load balancers in use by this environment.
|
||||
* `queues` - SQS queues in use by this environment.
|
||||
* `triggers` - Autoscaling triggers in use by this environment.
|
||||
|
||||
|
||||
|
||||
[1]: http://docs.aws.amazon.com/fr_fr/elasticbeanstalk/latest/dg/concepts.platforms.html
|
||||
|
|
Loading…
Reference in New Issue