provider/aws: Add Elastic Beanstalk Application, Configuration Template, and Environment

This adds support for Elastic Beanstalk Applications, Configuration Templates,
and Environments.

This is a combined work of @catsby, @dharrisio, @Bowbaq, and @jen20
This commit is contained in:
clint shryock 2016-03-07 14:42:30 -06:00
parent 2458bfe563
commit f0d3176999
19 changed files with 6746 additions and 127 deletions

5
Godeps/Godeps.json generated
View File

@ -376,6 +376,11 @@
"Comment": "v1.1.2",
"Rev": "8041be5461786460d86b4358305fbdf32d37cfb2"
},
{
"ImportPath": "github.com/aws/aws-sdk-go/service/elasticbeanstalk",
"Comment": "v1.1.0",
"Rev": "be2ec39e520e3c4088c0c6288055bdc8184a89ee"
},
{
"ImportPath": "github.com/aws/aws-sdk-go/service/elasticsearchservice",
"Comment": "v1.1.2",

View File

@ -35,6 +35,7 @@ import (
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/aws/aws-sdk-go/service/efs"
"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/firehose"
@ -98,6 +99,7 @@ type AWSClient struct {
kinesisconn *kinesis.Kinesis
firehoseconn *firehose.Firehose
elasticacheconn *elasticache.ElastiCache
elasticbeanstalkconn *elasticbeanstalk.ElasticBeanstalk
lambdaconn *lambda.Lambda
opsworksconn *opsworks.OpsWorks
glacierconn *glacier.Glacier
@ -213,6 +215,9 @@ func (c *Config) Client() (interface{}, error) {
kinesisSess := session.New(&awsKinesisConfig)
client.kinesisconn = kinesis.New(kinesisSess)
log.Println("[INFO] Initializing Elastic Beanstalk Connection")
client.elasticbeanstalkconn = elasticbeanstalk.New(sess)
authErr := c.ValidateAccountId(client.iamconn)
if authErr != nil {
errs = append(errs, authErr)

View File

@ -158,6 +158,9 @@ func Provider() terraform.ResourceProvider {
"aws_elasticache_parameter_group": resourceAwsElasticacheParameterGroup(),
"aws_elasticache_security_group": resourceAwsElasticacheSecurityGroup(),
"aws_elasticache_subnet_group": resourceAwsElasticacheSubnetGroup(),
"aws_elastic_beanstalk_application": resourceAwsElasticBeanstalkApplication(),
"aws_elastic_beanstalk_configuration_template": resourceAwsElasticBeanstalkConfigurationTemplate(),
"aws_elastic_beanstalk_environment": resourceAwsElasticBeanstalkEnvironment(),
"aws_elasticsearch_domain": resourceAwsElasticSearchDomain(),
"aws_elb": resourceAwsElb(),
"aws_flow_log": resourceAwsFlowLog(),

View File

@ -0,0 +1,147 @@
package aws
import (
"fmt"
"log"
"time"
"github.com/hashicorp/terraform/helper/schema"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/hashicorp/terraform/helper/resource"
)
func resourceAwsElasticBeanstalkApplication() *schema.Resource {
return &schema.Resource{
Create: resourceAwsElasticBeanstalkApplicationCreate,
Read: resourceAwsElasticBeanstalkApplicationRead,
Update: resourceAwsElasticBeanstalkApplicationUpdate,
Delete: resourceAwsElasticBeanstalkApplicationDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
},
}
}
func resourceAwsElasticBeanstalkApplicationCreate(d *schema.ResourceData, meta interface{}) error {
beanstalkConn := meta.(*AWSClient).elasticbeanstalkconn
// Get the name and description
name := d.Get("name").(string)
description := d.Get("description").(string)
log.Printf("[DEBUG] Elastic Beanstalk application create: %s, description: %s", name, description)
req := &elasticbeanstalk.CreateApplicationInput{
ApplicationName: aws.String(name),
Description: aws.String(description),
}
_, err := beanstalkConn.CreateApplication(req)
if err != nil {
return err
}
d.SetId(name)
return resourceAwsElasticBeanstalkApplicationRead(d, meta)
}
func resourceAwsElasticBeanstalkApplicationUpdate(d *schema.ResourceData, meta interface{}) error {
beanstalkConn := meta.(*AWSClient).elasticbeanstalkconn
if d.HasChange("description") {
if err := resourceAwsElasticBeanstalkApplicationDescriptionUpdate(beanstalkConn, d); err != nil {
return err
}
}
return resourceAwsElasticBeanstalkApplicationRead(d, meta)
}
func resourceAwsElasticBeanstalkApplicationDescriptionUpdate(beanstalkConn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
name := d.Get("name").(string)
description := d.Get("description").(string)
log.Printf("[DEBUG] Elastic Beanstalk application: %s, update description: %s", name, description)
_, err := beanstalkConn.UpdateApplication(&elasticbeanstalk.UpdateApplicationInput{
ApplicationName: aws.String(name),
Description: aws.String(description),
})
return err
}
func resourceAwsElasticBeanstalkApplicationRead(d *schema.ResourceData, meta interface{}) error {
a, err := getBeanstalkApplication(d, meta)
if err != nil {
return err
}
if a == nil {
return err
}
d.Set("description", a.Description)
return nil
}
func resourceAwsElasticBeanstalkApplicationDelete(d *schema.ResourceData, meta interface{}) error {
beanstalkConn := meta.(*AWSClient).elasticbeanstalkconn
a, err := getBeanstalkApplication(d, meta)
if err != nil {
return err
}
_, err = beanstalkConn.DeleteApplication(&elasticbeanstalk.DeleteApplicationInput{
ApplicationName: aws.String(d.Id()),
})
return resource.Retry(10*time.Second, func() error {
if a, _ = getBeanstalkApplication(d, meta); a != nil {
return fmt.Errorf("Beanstalk Application still exists")
}
return nil
})
}
func getBeanstalkApplication(
d *schema.ResourceData,
meta interface{}) (*elasticbeanstalk.ApplicationDescription, error) {
conn := meta.(*AWSClient).elasticbeanstalkconn
resp, err := conn.DescribeApplications(&elasticbeanstalk.DescribeApplicationsInput{
ApplicationNames: []*string{aws.String(d.Id())},
})
if err != nil {
if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() != "InvalidBeanstalkAppID.NotFound" {
log.Printf("[Err] Error reading Elastic Beanstalk Application (%s): Application not found", d.Id())
d.SetId("")
return nil, nil
}
return nil, err
}
switch {
case len(resp.Applications) > 1:
return nil, fmt.Errorf("Error %d Applications matched, expected 1", len(resp.Applications))
case len(resp.Applications) == 0:
d.SetId("")
return nil, nil
default:
return resp.Applications[0], nil
}
}

View File

@ -0,0 +1,100 @@
package aws
import (
"fmt"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAWSBeanstalkApp_basic(t *testing.T) {
var app elasticbeanstalk.ApplicationDescription
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBeanstalkAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccBeanstalkAppConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckBeanstalkAppExists("aws_elastic_beanstalk_application.tftest", &app),
),
},
},
})
}
func testAccCheckBeanstalkAppDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_elastic_beanstalk_application" {
continue
}
// Try to find the application
DescribeBeanstalkAppOpts := &elasticbeanstalk.DescribeApplicationsInput{
ApplicationNames: []*string{aws.String(rs.Primary.ID)},
}
resp, err := conn.DescribeApplications(DescribeBeanstalkAppOpts)
if err == nil {
if len(resp.Applications) > 0 {
return fmt.Errorf("Elastic Beanstalk Application still exists.")
}
return nil
}
// Verify the error is what we want
ec2err, ok := err.(awserr.Error)
if !ok {
return err
}
if ec2err.Code() != "InvalidBeanstalkAppID.NotFound" {
return err
}
}
return nil
}
func testAccCheckBeanstalkAppExists(n string, app *elasticbeanstalk.ApplicationDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Elastic Beanstalk app ID is not set")
}
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
DescribeBeanstalkAppOpts := &elasticbeanstalk.DescribeApplicationsInput{
ApplicationNames: []*string{aws.String(rs.Primary.ID)},
}
resp, err := conn.DescribeApplications(DescribeBeanstalkAppOpts)
if err != nil {
return err
}
if len(resp.Applications) == 0 {
return fmt.Errorf("Elastic Beanstalk Application not found.")
}
*app = *resp.Applications[0]
return nil
}
}
const testAccBeanstalkAppConfig = `
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
description = "tf-test-desc"
}
`

View File

@ -0,0 +1,242 @@
package aws
import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
)
func resourceAwsElasticBeanstalkConfigurationTemplate() *schema.Resource {
return &schema.Resource{
Create: resourceAwsElasticBeanstalkConfigurationTemplateCreate,
Read: resourceAwsElasticBeanstalkConfigurationTemplateRead,
Update: resourceAwsElasticBeanstalkConfigurationTemplateUpdate,
Delete: resourceAwsElasticBeanstalkConfigurationTemplateDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"application": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"environment_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"option_settings": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"namespace": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"option_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"value": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
},
Set: optionSettingHash,
},
"solution_stack_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}
}
func resourceAwsElasticBeanstalkConfigurationTemplateCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
// Get the relevant properties
name := d.Get("name").(string)
appName := d.Get("application").(string)
optionSettings := gatherOptionSettings(d)
opts := elasticbeanstalk.CreateConfigurationTemplateInput{
ApplicationName: aws.String(appName),
TemplateName: aws.String(name),
OptionSettings: optionSettings,
}
if attr, ok := d.GetOk("description"); ok {
opts.Description = aws.String(attr.(string))
}
if attr, ok := d.GetOk("environment_id"); ok {
opts.EnvironmentId = aws.String(attr.(string))
}
if attr, ok := d.GetOk("solution_stack_name"); ok {
opts.SolutionStackName = aws.String(attr.(string))
}
log.Printf("[DEBUG] Elastic Beanstalk configuration template create opts: %s", opts)
if _, err := conn.CreateConfigurationTemplate(&opts); err != nil {
return fmt.Errorf("Error creating Elastic Beanstalk configuration template: %s", err)
}
d.SetId(name)
return resourceAwsElasticBeanstalkConfigurationTemplateRead(d, meta)
}
func resourceAwsElasticBeanstalkConfigurationTemplateRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
log.Printf("[DEBUG] Elastic Beanstalk configuration template read: %s", d.Get("name").(string))
resp, err := conn.DescribeConfigurationSettings(&elasticbeanstalk.DescribeConfigurationSettingsInput{
TemplateName: aws.String(d.Id()),
ApplicationName: aws.String(d.Get("application").(string)),
})
if err != nil {
return err
}
// if len(resp.ConfigurationSettings) > 1 {
// settings := make(map[string]map[string]string)
// for _, setting := range resp.ConfigurationSettings {
// k := fmt.Sprintf("%s.%s", setting.)
// }
// }
if len(resp.ConfigurationSettings) != 1 {
log.Printf("[DEBUG] Elastic Beanstalk unexpected describe configuration template response: %+v", resp)
return fmt.Errorf("Error reading application properties: found %d applications, expected 1", len(resp.ConfigurationSettings))
}
d.Set("description", resp.ConfigurationSettings[0].Description)
return nil
}
func resourceAwsElasticBeanstalkConfigurationTemplateUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
log.Printf("[DEBUG] Elastic Beanstalk configuration template update: %s", d.Get("name").(string))
if d.HasChange("description") {
if err := resourceAwsElasticBeanstalkConfigurationTemplateDescriptionUpdate(conn, d); err != nil {
return err
}
}
if d.HasChange("option_settings") {
if err := resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn, d); err != nil {
return err
}
}
return resourceAwsElasticBeanstalkConfigurationTemplateRead(d, meta)
}
func resourceAwsElasticBeanstalkConfigurationTemplateDescriptionUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
_, err := conn.UpdateConfigurationTemplate(&elasticbeanstalk.UpdateConfigurationTemplateInput{
ApplicationName: aws.String(d.Get("application").(string)),
TemplateName: aws.String(d.Get("name").(string)),
Description: aws.String(d.Get("description").(string)),
})
return err
}
func resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
if d.HasChange("option_settings") {
_, err := conn.ValidateConfigurationSettings(&elasticbeanstalk.ValidateConfigurationSettingsInput{
ApplicationName: aws.String(d.Get("application").(string)),
TemplateName: aws.String(d.Get("name").(string)),
OptionSettings: gatherOptionSettings(d),
})
if err != nil {
return err
}
o, n := d.GetChange("option_settings")
if o == nil {
o = new(schema.Set)
}
if n == nil {
n = new(schema.Set)
}
os := o.(*schema.Set)
ns := o.(*schema.Set)
remove := extractOptionSettings(os.Difference(ns))
add := extractOptionSettings(ns.Difference(os))
req := &elasticbeanstalk.UpdateConfigurationTemplateInput{
ApplicationName: aws.String(d.Get("application").(string)),
TemplateName: aws.String(d.Get("name").(string)),
OptionSettings: add,
}
for _, elem := range remove {
req.OptionsToRemove = append(req.OptionsToRemove, &elasticbeanstalk.OptionSpecification{
Namespace: elem.Namespace,
OptionName: elem.OptionName,
})
}
if _, err := conn.UpdateConfigurationTemplate(req); err != nil {
return err
}
}
return nil
}
func resourceAwsElasticBeanstalkConfigurationTemplateDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
application := d.Get("application").(string)
_, err := conn.DeleteConfigurationTemplate(&elasticbeanstalk.DeleteConfigurationTemplateInput{
ApplicationName: aws.String(application),
TemplateName: aws.String(d.Id()),
})
return err
}
func optionSettingHash(v interface{}) int {
rd := v.(*schema.ResourceData)
namespace := rd.Get("namespace").(string)
optionName := rd.Get("option_name").(string)
return hashcode.String(fmt.Sprintf("%s.%s", namespace, optionName))
}
func gatherOptionSettings(d *schema.ResourceData) []*elasticbeanstalk.ConfigurationOptionSetting {
optionSettingsSet, ok := d.Get("option_settings").(*schema.Set)
if !ok || optionSettingsSet == nil {
optionSettingsSet = new(schema.Set)
}
return extractOptionSettings(optionSettingsSet)
}

View File

@ -0,0 +1,121 @@
package aws
import (
"fmt"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAWSBeanstalkConfigurationTemplate_basic(t *testing.T) {
var config elasticbeanstalk.ConfigurationSettingsDescription
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBeanstalkConfigurationTemplateDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccBeanstalkConfigurationTemplateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config),
),
},
},
})
}
func testAccCheckBeanstalkConfigurationTemplateDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_elastic_beanstalk_configuration_template" {
continue
}
// Try to find the Configuration Template
opts := elasticbeanstalk.DescribeConfigurationSettingsInput{
TemplateName: aws.String(rs.Primary.ID),
ApplicationName: aws.String(rs.Primary.Attributes["application"]),
}
resp, err := conn.DescribeConfigurationSettings(&opts)
if err == nil {
if len(resp.ConfigurationSettings) > 0 {
return fmt.Errorf("Elastic Beanstalk Application still exists.")
}
return nil
}
// Verify the error is what we want
ec2err, ok := err.(awserr.Error)
if !ok {
return err
}
switch {
case ec2err.Code() == "InvalidBeanstalkConfigurationTemplateID.NotFound":
return nil
// This error can be returned when the beanstalk application no longer exists.
case ec2err.Code() == "InvalidParameterValue":
return nil
default:
return err
}
}
return nil
}
func testAccCheckBeanstalkConfigurationTemplateExists(n string, config *elasticbeanstalk.ConfigurationSettingsDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Elastic Beanstalk config ID is not set")
}
opts := elasticbeanstalk.DescribeConfigurationSettingsInput{
TemplateName: aws.String(rs.Primary.ID),
ApplicationName: aws.String(rs.Primary.Attributes["application"]),
}
resp, err := conn.DescribeConfigurationSettings(&opts)
if err != nil {
return err
}
if len(resp.ConfigurationSettings) == 0 {
return fmt.Errorf("Elastic Beanstalk Configurations not found.")
}
*config = *resp.ConfigurationSettings[0]
return nil
}
}
const testAccBeanstalkConfigurationTemplateConfig = `
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
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"
}
`

View File

@ -0,0 +1,549 @@
package aws
import (
"fmt"
"log"
"sort"
"strings"
"time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
)
func resourceAwsElasticBeanstalkOptionSetting() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"namespace": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"value": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
},
}
}
func resourceAwsElasticBeanstalkEnvironment() *schema.Resource {
return &schema.Resource{
Create: resourceAwsElasticBeanstalkEnvironmentCreate,
Read: resourceAwsElasticBeanstalkEnvironmentRead,
Update: resourceAwsElasticBeanstalkEnvironmentUpdate,
Delete: resourceAwsElasticBeanstalkEnvironmentDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"application": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"cname": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"tier": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
switch value {
case
"Worker",
"WebServer":
return
}
errors = append(errors, fmt.Errorf("%s is not a valid tier. Valid options are WebServer or Worker", value))
return
},
ForceNew: true,
},
"setting": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: resourceAwsElasticBeanstalkOptionSetting(),
Set: optionSettingValueHash,
},
"all_settings": &schema.Schema{
Type: schema.TypeSet,
Computed: true,
Elem: resourceAwsElasticBeanstalkOptionSetting(),
Set: optionSettingValueHash,
},
"solution_stack_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"template_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"solution_stack_name"},
},
"tags": tagsSchema(),
},
}
}
func resourceAwsElasticBeanstalkEnvironmentCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
// Get values from config
name := d.Get("name").(string)
cname := d.Get("cname").(string)
tier := d.Get("tier").(string)
app := d.Get("application").(string)
desc := d.Get("description").(string)
settings := d.Get("setting").(*schema.Set)
solutionStack := d.Get("solution_stack_name").(string)
templateName := d.Get("template_name").(string)
// TODO set tags
// Note: at time of writing, you cannot view or edit Tags after creation
// d.Set("tags", tagsToMap(instance.Tags))
createOpts := elasticbeanstalk.CreateEnvironmentInput{
EnvironmentName: aws.String(name),
ApplicationName: aws.String(app),
OptionSettings: extractOptionSettings(settings),
Tags: tagsFromMapBeanstalk(d.Get("tags").(map[string]interface{})),
}
if desc != "" {
createOpts.Description = aws.String(desc)
}
if cname != "" {
createOpts.CNAMEPrefix = aws.String(cname)
}
if tier != "" {
var tierType string
switch tier {
case "WebServer":
tierType = "Standard"
case "Worker":
tierType = "SQS/HTTP"
}
environmentTier := elasticbeanstalk.EnvironmentTier{
Name: aws.String(tier),
Type: aws.String(tierType),
}
createOpts.Tier = &environmentTier
}
if solutionStack != "" {
createOpts.SolutionStackName = aws.String(solutionStack)
}
if templateName != "" {
createOpts.TemplateName = aws.String(templateName)
}
log.Printf("[DEBUG] Elastic Beanstalk Environment create opts: %s", createOpts)
resp, err := conn.CreateEnvironment(&createOpts)
if err != nil {
return err
}
// Assign the application name as the resource ID
d.SetId(*resp.EnvironmentId)
stateConf := &resource.StateChangeConf{
Pending: []string{"Launching", "Updating"},
Target: []string{"Ready"},
Refresh: environmentStateRefreshFunc(conn, d.Id()),
Timeout: 10 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
_, err = stateConf.WaitForState()
if err != nil {
return fmt.Errorf(
"Error waiting for Elastic Beanstalk Environment (%s) to become ready: %s",
d.Id(), err)
}
return resourceAwsElasticBeanstalkEnvironmentRead(d, meta)
}
func resourceAwsElasticBeanstalkEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
if d.HasChange("description") {
if err := resourceAwsElasticBeanstalkEnvironmentDescriptionUpdate(conn, d); err != nil {
return err
}
}
if d.HasChange("solution_stack_name") {
if err := resourceAwsElasticBeanstalkEnvironmentSolutionStackUpdate(conn, d); err != nil {
return err
}
}
if d.HasChange("setting") {
if err := resourceAwsElasticBeanstalkEnvironmentOptionSettingsUpdate(conn, d); err != nil {
return err
}
}
return resourceAwsElasticBeanstalkEnvironmentRead(d, meta)
}
func resourceAwsElasticBeanstalkEnvironmentDescriptionUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
name := d.Get("name").(string)
desc := d.Get("description").(string)
envId := d.Id()
log.Printf("[DEBUG] Elastic Beanstalk application: %s, update description: %s", name, desc)
_, err := conn.UpdateEnvironment(&elasticbeanstalk.UpdateEnvironmentInput{
EnvironmentId: aws.String(envId),
Description: aws.String(desc),
})
return err
}
func resourceAwsElasticBeanstalkEnvironmentOptionSettingsUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
name := d.Get("name").(string)
envId := d.Id()
log.Printf("[DEBUG] Elastic Beanstalk application: %s, update options", name)
req := &elasticbeanstalk.UpdateEnvironmentInput{
EnvironmentId: aws.String(envId),
}
if d.HasChange("setting") {
o, n := d.GetChange("setting")
if o == nil {
o = &schema.Set{F: optionSettingValueHash}
}
if n == nil {
n = &schema.Set{F: optionSettingValueHash}
}
os := o.(*schema.Set)
ns := n.(*schema.Set)
req.OptionSettings = extractOptionSettings(ns.Difference(os))
}
if _, err := conn.UpdateEnvironment(req); err != nil {
return err
}
return nil
}
func resourceAwsElasticBeanstalkEnvironmentSolutionStackUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error {
name := d.Get("name").(string)
solutionStack := d.Get("solution_stack_name").(string)
envId := d.Id()
log.Printf("[DEBUG] Elastic Beanstalk application: %s, update solution_stack_name: %s", name, solutionStack)
_, err := conn.UpdateEnvironment(&elasticbeanstalk.UpdateEnvironmentInput{
EnvironmentId: aws.String(envId),
SolutionStackName: aws.String(solutionStack),
})
return err
}
func resourceAwsElasticBeanstalkEnvironmentRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
app := d.Get("application").(string)
envId := d.Id()
log.Printf("[DEBUG] Elastic Beanstalk environment read %s: id %s", d.Get("name").(string), d.Id())
resp, err := conn.DescribeEnvironments(&elasticbeanstalk.DescribeEnvironmentsInput{
ApplicationName: aws.String(app),
EnvironmentIds: []*string{aws.String(envId)},
})
if err != nil {
return err
}
if len(resp.Environments) == 0 {
log.Printf("[DEBUG] Elastic Beanstalk environment properties: could not find environment %s", d.Id())
d.SetId("")
return nil
} else if len(resp.Environments) != 1 {
return fmt.Errorf("Error reading application properties: found %d environments, expected 1", len(resp.Environments))
}
env := resp.Environments[0]
if *env.Status == "Terminated" {
log.Printf("[DEBUG] Elastic Beanstalk environment %s was terminated", d.Id())
d.SetId("")
return nil
}
if err := d.Set("description", env.Description); err != nil {
return err
}
if err := d.Set("cname", env.CNAME); err != nil {
return err
}
return resourceAwsElasticBeanstalkEnvironmentSettingsRead(d, meta)
}
func fetchAwsElasticBeanstalkEnvironmentSettings(d *schema.ResourceData, meta interface{}) (*schema.Set, error) {
conn := meta.(*AWSClient).elasticbeanstalkconn
app := d.Get("application").(string)
name := d.Get("name").(string)
resp, err := conn.DescribeConfigurationSettings(&elasticbeanstalk.DescribeConfigurationSettingsInput{
ApplicationName: aws.String(app),
EnvironmentName: aws.String(name),
})
if err != nil {
return nil, err
}
if len(resp.ConfigurationSettings) != 1 {
return nil, fmt.Errorf("Error reading environment settings: received %d settings groups, expected 1", len(resp.ConfigurationSettings))
}
settings := &schema.Set{F: optionSettingValueHash}
for _, optionSetting := range resp.ConfigurationSettings[0].OptionSettings {
m := map[string]interface{}{}
if optionSetting.Namespace != nil {
m["namespace"] = *optionSetting.Namespace
} else {
return nil, fmt.Errorf("Error reading environment settings: option setting with no namespace: %v", optionSetting)
}
if optionSetting.OptionName != nil {
m["name"] = *optionSetting.OptionName
} else {
return nil, fmt.Errorf("Error reading environment settings: option setting with no name: %v", optionSetting)
}
if optionSetting.Value != nil {
switch *optionSetting.OptionName {
case "SecurityGroups":
m["value"] = dropGeneratedSecurityGroup(*optionSetting.Value, meta)
case "Subnets", "ELBSubnets":
m["value"] = sortValues(*optionSetting.Value)
default:
m["value"] = *optionSetting.Value
}
}
settings.Add(m)
}
return settings, nil
}
func resourceAwsElasticBeanstalkEnvironmentSettingsRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Elastic Beanstalk environment settings read %s: id %s", d.Get("name").(string), d.Id())
allSettings, err := fetchAwsElasticBeanstalkEnvironmentSettings(d, meta)
if err != nil {
return err
}
settings := d.Get("setting").(*schema.Set)
log.Printf("[DEBUG] Elastic Beanstalk allSettings: %s", allSettings.GoString())
log.Printf("[DEBUG] Elastic Beanstalk settings: %s", settings.GoString())
// perform the set operation with only name/namespace as keys, excluding value
// this is so we override things in the settings resource data key with updated values
// from the api. we skip values we didn't know about before because there are so many
// defaults set by the eb api that we would delete many useful defaults.
//
// there is likely a better way to do this
allSettingsKeySet := schema.NewSet(optionSettingKeyHash, allSettings.List())
settingsKeySet := schema.NewSet(optionSettingKeyHash, settings.List())
updatedSettingsKeySet := allSettingsKeySet.Intersection(settingsKeySet)
log.Printf("[DEBUG] Elastic Beanstalk updatedSettingsKeySet: %s", updatedSettingsKeySet.GoString())
updatedSettings := schema.NewSet(optionSettingValueHash, updatedSettingsKeySet.List())
log.Printf("[DEBUG] Elastic Beanstalk updatedSettings: %s", updatedSettings.GoString())
if err := d.Set("all_settings", allSettings.List()); err != nil {
return err
}
if err := d.Set("setting", updatedSettings.List()); err != nil {
return err
}
return nil
}
func resourceAwsElasticBeanstalkEnvironmentDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticbeanstalkconn
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)
if err != nil {
return err
}
stateConf := &resource.StateChangeConf{
Pending: []string{"Terminating"},
Target: []string{"Terminated"},
Refresh: environmentStateRefreshFunc(conn, d.Id()),
Timeout: 10 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}
_, err = stateConf.WaitForState()
if err != nil {
return fmt.Errorf(
"Error waiting for Elastic Beanstalk Environment (%s) to become terminated: %s",
d.Id(), err)
}
return nil
}
// environmentStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// the creation of the Beanstalk Environment
func environmentStateRefreshFunc(conn *elasticbeanstalk.ElasticBeanstalk, environmentId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
resp, err := conn.DescribeEnvironments(&elasticbeanstalk.DescribeEnvironmentsInput{
EnvironmentIds: []*string{aws.String(environmentId)},
})
if err != nil {
log.Printf("[Err] Error waiting for Elastic Beanstalk Environment state: %s", err)
return -1, "failed", fmt.Errorf("[Err] Error waiting for Elastic Beanstalk Environment state: %s", err)
}
if resp == nil || len(resp.Environments) == 0 {
// Sometimes AWS just has consistency issues and doesn't see
// our instance yet. Return an empty state.
return nil, "", nil
}
var env *elasticbeanstalk.EnvironmentDescription
for _, e := range resp.Environments {
if environmentId == *e.EnvironmentId {
env = e
}
}
if env == nil {
return -1, "failed", fmt.Errorf("[Err] Error finding Elastic Beanstalk Environment, environment not found")
}
return env, *env.Status, nil
}
}
// we use the following two functions to allow us to split out defaults
// as they become overridden from within the template
func optionSettingValueHash(v interface{}) int {
rd := v.(map[string]interface{})
namespace := rd["namespace"].(string)
optionName := rd["name"].(string)
value, _ := rd["value"].(string)
hk := fmt.Sprintf("%s:%s=%s", namespace, optionName, sortValues(value))
log.Printf("[DEBUG] Elastic Beanstalk optionSettingValueHash(%#v): %s: hk=%s,hc=%d", v, optionName, hk, hashcode.String(hk))
return hashcode.String(hk)
}
func optionSettingKeyHash(v interface{}) int {
rd := v.(map[string]interface{})
namespace := rd["namespace"].(string)
optionName := rd["name"].(string)
hk := fmt.Sprintf("%s:%s", namespace, optionName)
log.Printf("[DEBUG] Elastic Beanstalk optionSettingKeyHash(%#v): %s: hk=%s,hc=%d", v, optionName, hk, hashcode.String(hk))
return hashcode.String(hk)
}
func sortValues(v string) string {
values := strings.Split(v, ",")
sort.Strings(values)
return strings.Join(values, ",")
}
func extractOptionSettings(s *schema.Set) []*elasticbeanstalk.ConfigurationOptionSetting {
settings := []*elasticbeanstalk.ConfigurationOptionSetting{}
if s != nil {
for _, setting := range s.List() {
settings = append(settings, &elasticbeanstalk.ConfigurationOptionSetting{
Namespace: aws.String(setting.(map[string]interface{})["namespace"].(string)),
OptionName: aws.String(setting.(map[string]interface{})["name"].(string)),
Value: aws.String(setting.(map[string]interface{})["value"].(string)),
})
}
}
return settings
}
func dropGeneratedSecurityGroup(settingValue string, meta interface{}) string {
conn := meta.(*AWSClient).ec2conn
groups := strings.Split(settingValue, ",")
resp, err := conn.DescribeSecurityGroups(&ec2.DescribeSecurityGroupsInput{
GroupIds: aws.StringSlice(groups),
})
if err != nil {
log.Printf("[DEBUG] Elastic Beanstalk error describing SecurityGroups: %v", err)
return settingValue
}
var legitGroups []string
for _, group := range resp.SecurityGroups {
log.Printf("[DEBUG] Elastic Beanstalk SecurityGroup: %v", *group.GroupName)
if !strings.HasPrefix(*group.GroupName, "awseb") {
legitGroups = append(legitGroups, *group.GroupId)
}
}
sort.Strings(legitGroups)
return strings.Join(legitGroups, ",")
}

View File

@ -0,0 +1,185 @@
package aws
import (
"fmt"
"log"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccAWSBeanstalkEnv_basic(t *testing.T) {
var app elasticbeanstalk.EnvironmentDescription
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),
),
},
},
})
}
func TestAccAWSBeanstalkEnv_tier(t *testing.T) {
var app elasticbeanstalk.EnvironmentDescription
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBeanstalkEnvDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccBeanstalkWorkerEnvConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckBeanstalkEnvTier("aws_elastic_beanstalk_environment.tfenvtest", &app),
),
},
},
})
}
func testAccCheckBeanstalkEnvDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_elastic_beanstalk_environment" {
continue
}
// Try to find the environment
describeBeanstalkEnvOpts := &elasticbeanstalk.DescribeEnvironmentsInput{
EnvironmentIds: []*string{aws.String(rs.Primary.ID)},
}
resp, err := conn.DescribeEnvironments(describeBeanstalkEnvOpts)
if err == nil {
switch {
case len(resp.Environments) > 1:
return fmt.Errorf("Error %d environments match, expected 1", len(resp.Environments))
case len(resp.Environments) == 1:
if *resp.Environments[0].Status == "Terminated" {
return nil
}
return fmt.Errorf("Elastic Beanstalk ENV still exists.")
default:
return nil
}
}
// Verify the error is what we want
ec2err, ok := err.(awserr.Error)
if !ok {
return err
}
if ec2err.Code() != "InvalidBeanstalkEnvID.NotFound" {
return err
}
}
return nil
}
func testAccCheckBeanstalkEnvExists(n string, app *elasticbeanstalk.EnvironmentDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Elastic Beanstalk ENV is not set")
}
env, err := describeBeanstalkEnv(testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn, aws.String(rs.Primary.ID))
if err != nil {
return err
}
*app = *env
return nil
}
}
func testAccCheckBeanstalkEnvTier(n string, app *elasticbeanstalk.EnvironmentDescription) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Elastic Beanstalk ENV is not set")
}
env, err := describeBeanstalkEnv(testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn, aws.String(rs.Primary.ID))
if err != nil {
return err
}
if *env.Tier.Name != "Worker" {
return fmt.Errorf("Beanstalk Environment tier is %s, expected Worker", *env.Tier.Name)
}
*app = *env
return nil
}
}
func describeBeanstalkEnv(conn *elasticbeanstalk.ElasticBeanstalk,
envID *string) (*elasticbeanstalk.EnvironmentDescription, error) {
describeBeanstalkEnvOpts := &elasticbeanstalk.DescribeEnvironmentsInput{
EnvironmentIds: []*string{envID},
}
log.Printf("[DEBUG] Elastic Beanstalk Environment TEST describe opts: %s", describeBeanstalkEnvOpts)
resp, err := conn.DescribeEnvironments(describeBeanstalkEnvOpts)
if err != nil {
return &elasticbeanstalk.EnvironmentDescription{}, err
}
if len(resp.Environments) == 0 {
return &elasticbeanstalk.EnvironmentDescription{}, fmt.Errorf("Elastic Beanstalk ENV not found.")
}
if len(resp.Environments) > 1 {
return &elasticbeanstalk.EnvironmentDescription{}, fmt.Errorf("Found %d environments, expected 1.", len(resp.Environments))
}
return resp.Environments[0], nil
}
const testAccBeanstalkEnvConfig = `
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
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.09 v2.0.8 running Go 1.4"
#solution_stack_name =
}
`
const testAccBeanstalkWorkerEnvConfig = `
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
description = "tf-test-desc"
}
resource "aws_elastic_beanstalk_environment" "tfenvtest" {
name = "tf-test-name"
application = "${aws_elastic_beanstalk_application.tftest.name}"
tier = "Worker"
solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.4 running Go 1.4"
}
`

View File

@ -0,0 +1,52 @@
package aws
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
)
// diffTags takes our tags locally and the ones remotely and returns
// the set of tags that must be created, and the set of tags that must
// be destroyed.
func diffTagsBeanstalk(oldTags, newTags []*elasticbeanstalk.Tag) ([]*elasticbeanstalk.Tag, []*elasticbeanstalk.Tag) {
// First, we're creating everything we have
create := make(map[string]interface{})
for _, t := range newTags {
create[*t.Key] = *t.Value
}
// Build the list of what to remove
var remove []*elasticbeanstalk.Tag
for _, t := range oldTags {
old, ok := create[*t.Key]
if !ok || old != *t.Value {
// Delete it!
remove = append(remove, t)
}
}
return tagsFromMapBeanstalk(create), remove
}
// tagsFromMap returns the tags for the given map of data.
func tagsFromMapBeanstalk(m map[string]interface{}) []*elasticbeanstalk.Tag {
var result []*elasticbeanstalk.Tag
for k, v := range m {
result = append(result, &elasticbeanstalk.Tag{
Key: aws.String(k),
Value: aws.String(v.(string)),
})
}
return result
}
// tagsToMap turns the list of tags into a map.
func tagsToMapBeanstalk(ts []*elasticbeanstalk.Tag) map[string]string {
result := make(map[string]string)
for _, t := range ts {
result[*t.Key] = *t.Value
}
return result
}

View File

@ -0,0 +1,85 @@
package aws
import (
"fmt"
"reflect"
"testing"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestDiffBeanstalkTags(t *testing.T) {
cases := []struct {
Old, New map[string]interface{}
Create, Remove map[string]string
}{
// Basic add/remove
{
Old: map[string]interface{}{
"foo": "bar",
},
New: map[string]interface{}{
"bar": "baz",
},
Create: map[string]string{
"bar": "baz",
},
Remove: map[string]string{
"foo": "bar",
},
},
// Modify
{
Old: map[string]interface{}{
"foo": "bar",
},
New: map[string]interface{}{
"foo": "baz",
},
Create: map[string]string{
"foo": "baz",
},
Remove: map[string]string{
"foo": "bar",
},
},
}
for i, tc := range cases {
c, r := diffTagsBeanstalk(tagsFromMapBeanstalk(tc.Old), tagsFromMapBeanstalk(tc.New))
cm := tagsToMapBeanstalk(c)
rm := tagsToMapBeanstalk(r)
if !reflect.DeepEqual(cm, tc.Create) {
t.Fatalf("%d: bad create: %#v", i, cm)
}
if !reflect.DeepEqual(rm, tc.Remove) {
t.Fatalf("%d: bad remove: %#v", i, rm)
}
}
}
// testAccCheckTags can be used to check the tags on a resource.
func testAccCheckBeanstalkTags(
ts *[]*elasticbeanstalk.Tag, key string, value string) resource.TestCheckFunc {
return func(s *terraform.State) error {
m := tagsToMapBeanstalk(*ts)
v, ok := m[key]
if value != "" && !ok {
return fmt.Errorf("Missing tag: %s", key)
} else if value == "" && ok {
return fmt.Errorf("Extra tag: %s", key)
}
if value == "" {
return nil
}
if v != value {
return fmt.Errorf("%s: bad value: %s", key, v)
}
return nil
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,148 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Package elasticbeanstalkiface provides an interface for the AWS Elastic Beanstalk.
package elasticbeanstalkiface
import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
)
// ElasticBeanstalkAPI is the interface type for elasticbeanstalk.ElasticBeanstalk.
type ElasticBeanstalkAPI interface {
AbortEnvironmentUpdateRequest(*elasticbeanstalk.AbortEnvironmentUpdateInput) (*request.Request, *elasticbeanstalk.AbortEnvironmentUpdateOutput)
AbortEnvironmentUpdate(*elasticbeanstalk.AbortEnvironmentUpdateInput) (*elasticbeanstalk.AbortEnvironmentUpdateOutput, error)
CheckDNSAvailabilityRequest(*elasticbeanstalk.CheckDNSAvailabilityInput) (*request.Request, *elasticbeanstalk.CheckDNSAvailabilityOutput)
CheckDNSAvailability(*elasticbeanstalk.CheckDNSAvailabilityInput) (*elasticbeanstalk.CheckDNSAvailabilityOutput, error)
ComposeEnvironmentsRequest(*elasticbeanstalk.ComposeEnvironmentsInput) (*request.Request, *elasticbeanstalk.EnvironmentDescriptionsMessage)
ComposeEnvironments(*elasticbeanstalk.ComposeEnvironmentsInput) (*elasticbeanstalk.EnvironmentDescriptionsMessage, error)
CreateApplicationRequest(*elasticbeanstalk.CreateApplicationInput) (*request.Request, *elasticbeanstalk.ApplicationDescriptionMessage)
CreateApplication(*elasticbeanstalk.CreateApplicationInput) (*elasticbeanstalk.ApplicationDescriptionMessage, error)
CreateApplicationVersionRequest(*elasticbeanstalk.CreateApplicationVersionInput) (*request.Request, *elasticbeanstalk.ApplicationVersionDescriptionMessage)
CreateApplicationVersion(*elasticbeanstalk.CreateApplicationVersionInput) (*elasticbeanstalk.ApplicationVersionDescriptionMessage, error)
CreateConfigurationTemplateRequest(*elasticbeanstalk.CreateConfigurationTemplateInput) (*request.Request, *elasticbeanstalk.ConfigurationSettingsDescription)
CreateConfigurationTemplate(*elasticbeanstalk.CreateConfigurationTemplateInput) (*elasticbeanstalk.ConfigurationSettingsDescription, error)
CreateEnvironmentRequest(*elasticbeanstalk.CreateEnvironmentInput) (*request.Request, *elasticbeanstalk.EnvironmentDescription)
CreateEnvironment(*elasticbeanstalk.CreateEnvironmentInput) (*elasticbeanstalk.EnvironmentDescription, error)
CreateStorageLocationRequest(*elasticbeanstalk.CreateStorageLocationInput) (*request.Request, *elasticbeanstalk.CreateStorageLocationOutput)
CreateStorageLocation(*elasticbeanstalk.CreateStorageLocationInput) (*elasticbeanstalk.CreateStorageLocationOutput, error)
DeleteApplicationRequest(*elasticbeanstalk.DeleteApplicationInput) (*request.Request, *elasticbeanstalk.DeleteApplicationOutput)
DeleteApplication(*elasticbeanstalk.DeleteApplicationInput) (*elasticbeanstalk.DeleteApplicationOutput, error)
DeleteApplicationVersionRequest(*elasticbeanstalk.DeleteApplicationVersionInput) (*request.Request, *elasticbeanstalk.DeleteApplicationVersionOutput)
DeleteApplicationVersion(*elasticbeanstalk.DeleteApplicationVersionInput) (*elasticbeanstalk.DeleteApplicationVersionOutput, error)
DeleteConfigurationTemplateRequest(*elasticbeanstalk.DeleteConfigurationTemplateInput) (*request.Request, *elasticbeanstalk.DeleteConfigurationTemplateOutput)
DeleteConfigurationTemplate(*elasticbeanstalk.DeleteConfigurationTemplateInput) (*elasticbeanstalk.DeleteConfigurationTemplateOutput, error)
DeleteEnvironmentConfigurationRequest(*elasticbeanstalk.DeleteEnvironmentConfigurationInput) (*request.Request, *elasticbeanstalk.DeleteEnvironmentConfigurationOutput)
DeleteEnvironmentConfiguration(*elasticbeanstalk.DeleteEnvironmentConfigurationInput) (*elasticbeanstalk.DeleteEnvironmentConfigurationOutput, error)
DescribeApplicationVersionsRequest(*elasticbeanstalk.DescribeApplicationVersionsInput) (*request.Request, *elasticbeanstalk.DescribeApplicationVersionsOutput)
DescribeApplicationVersions(*elasticbeanstalk.DescribeApplicationVersionsInput) (*elasticbeanstalk.DescribeApplicationVersionsOutput, error)
DescribeApplicationsRequest(*elasticbeanstalk.DescribeApplicationsInput) (*request.Request, *elasticbeanstalk.DescribeApplicationsOutput)
DescribeApplications(*elasticbeanstalk.DescribeApplicationsInput) (*elasticbeanstalk.DescribeApplicationsOutput, error)
DescribeConfigurationOptionsRequest(*elasticbeanstalk.DescribeConfigurationOptionsInput) (*request.Request, *elasticbeanstalk.DescribeConfigurationOptionsOutput)
DescribeConfigurationOptions(*elasticbeanstalk.DescribeConfigurationOptionsInput) (*elasticbeanstalk.DescribeConfigurationOptionsOutput, error)
DescribeConfigurationSettingsRequest(*elasticbeanstalk.DescribeConfigurationSettingsInput) (*request.Request, *elasticbeanstalk.DescribeConfigurationSettingsOutput)
DescribeConfigurationSettings(*elasticbeanstalk.DescribeConfigurationSettingsInput) (*elasticbeanstalk.DescribeConfigurationSettingsOutput, error)
DescribeEnvironmentHealthRequest(*elasticbeanstalk.DescribeEnvironmentHealthInput) (*request.Request, *elasticbeanstalk.DescribeEnvironmentHealthOutput)
DescribeEnvironmentHealth(*elasticbeanstalk.DescribeEnvironmentHealthInput) (*elasticbeanstalk.DescribeEnvironmentHealthOutput, error)
DescribeEnvironmentResourcesRequest(*elasticbeanstalk.DescribeEnvironmentResourcesInput) (*request.Request, *elasticbeanstalk.DescribeEnvironmentResourcesOutput)
DescribeEnvironmentResources(*elasticbeanstalk.DescribeEnvironmentResourcesInput) (*elasticbeanstalk.DescribeEnvironmentResourcesOutput, error)
DescribeEnvironmentsRequest(*elasticbeanstalk.DescribeEnvironmentsInput) (*request.Request, *elasticbeanstalk.EnvironmentDescriptionsMessage)
DescribeEnvironments(*elasticbeanstalk.DescribeEnvironmentsInput) (*elasticbeanstalk.EnvironmentDescriptionsMessage, error)
DescribeEventsRequest(*elasticbeanstalk.DescribeEventsInput) (*request.Request, *elasticbeanstalk.DescribeEventsOutput)
DescribeEvents(*elasticbeanstalk.DescribeEventsInput) (*elasticbeanstalk.DescribeEventsOutput, error)
DescribeEventsPages(*elasticbeanstalk.DescribeEventsInput, func(*elasticbeanstalk.DescribeEventsOutput, bool) bool) error
DescribeInstancesHealthRequest(*elasticbeanstalk.DescribeInstancesHealthInput) (*request.Request, *elasticbeanstalk.DescribeInstancesHealthOutput)
DescribeInstancesHealth(*elasticbeanstalk.DescribeInstancesHealthInput) (*elasticbeanstalk.DescribeInstancesHealthOutput, error)
ListAvailableSolutionStacksRequest(*elasticbeanstalk.ListAvailableSolutionStacksInput) (*request.Request, *elasticbeanstalk.ListAvailableSolutionStacksOutput)
ListAvailableSolutionStacks(*elasticbeanstalk.ListAvailableSolutionStacksInput) (*elasticbeanstalk.ListAvailableSolutionStacksOutput, error)
RebuildEnvironmentRequest(*elasticbeanstalk.RebuildEnvironmentInput) (*request.Request, *elasticbeanstalk.RebuildEnvironmentOutput)
RebuildEnvironment(*elasticbeanstalk.RebuildEnvironmentInput) (*elasticbeanstalk.RebuildEnvironmentOutput, error)
RequestEnvironmentInfoRequest(*elasticbeanstalk.RequestEnvironmentInfoInput) (*request.Request, *elasticbeanstalk.RequestEnvironmentInfoOutput)
RequestEnvironmentInfo(*elasticbeanstalk.RequestEnvironmentInfoInput) (*elasticbeanstalk.RequestEnvironmentInfoOutput, error)
RestartAppServerRequest(*elasticbeanstalk.RestartAppServerInput) (*request.Request, *elasticbeanstalk.RestartAppServerOutput)
RestartAppServer(*elasticbeanstalk.RestartAppServerInput) (*elasticbeanstalk.RestartAppServerOutput, error)
RetrieveEnvironmentInfoRequest(*elasticbeanstalk.RetrieveEnvironmentInfoInput) (*request.Request, *elasticbeanstalk.RetrieveEnvironmentInfoOutput)
RetrieveEnvironmentInfo(*elasticbeanstalk.RetrieveEnvironmentInfoInput) (*elasticbeanstalk.RetrieveEnvironmentInfoOutput, error)
SwapEnvironmentCNAMEsRequest(*elasticbeanstalk.SwapEnvironmentCNAMEsInput) (*request.Request, *elasticbeanstalk.SwapEnvironmentCNAMEsOutput)
SwapEnvironmentCNAMEs(*elasticbeanstalk.SwapEnvironmentCNAMEsInput) (*elasticbeanstalk.SwapEnvironmentCNAMEsOutput, error)
TerminateEnvironmentRequest(*elasticbeanstalk.TerminateEnvironmentInput) (*request.Request, *elasticbeanstalk.EnvironmentDescription)
TerminateEnvironment(*elasticbeanstalk.TerminateEnvironmentInput) (*elasticbeanstalk.EnvironmentDescription, error)
UpdateApplicationRequest(*elasticbeanstalk.UpdateApplicationInput) (*request.Request, *elasticbeanstalk.ApplicationDescriptionMessage)
UpdateApplication(*elasticbeanstalk.UpdateApplicationInput) (*elasticbeanstalk.ApplicationDescriptionMessage, error)
UpdateApplicationVersionRequest(*elasticbeanstalk.UpdateApplicationVersionInput) (*request.Request, *elasticbeanstalk.ApplicationVersionDescriptionMessage)
UpdateApplicationVersion(*elasticbeanstalk.UpdateApplicationVersionInput) (*elasticbeanstalk.ApplicationVersionDescriptionMessage, error)
UpdateConfigurationTemplateRequest(*elasticbeanstalk.UpdateConfigurationTemplateInput) (*request.Request, *elasticbeanstalk.ConfigurationSettingsDescription)
UpdateConfigurationTemplate(*elasticbeanstalk.UpdateConfigurationTemplateInput) (*elasticbeanstalk.ConfigurationSettingsDescription, error)
UpdateEnvironmentRequest(*elasticbeanstalk.UpdateEnvironmentInput) (*request.Request, *elasticbeanstalk.EnvironmentDescription)
UpdateEnvironment(*elasticbeanstalk.UpdateEnvironmentInput) (*elasticbeanstalk.EnvironmentDescription, error)
ValidateConfigurationSettingsRequest(*elasticbeanstalk.ValidateConfigurationSettingsInput) (*request.Request, *elasticbeanstalk.ValidateConfigurationSettingsOutput)
ValidateConfigurationSettings(*elasticbeanstalk.ValidateConfigurationSettingsInput) (*elasticbeanstalk.ValidateConfigurationSettingsOutput, error)
}
var _ ElasticBeanstalkAPI = (*elasticbeanstalk.ElasticBeanstalk)(nil)

View File

@ -0,0 +1,839 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
package elasticbeanstalk_test
import (
"bytes"
"fmt"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
)
var _ time.Duration
var _ bytes.Buffer
func ExampleElasticBeanstalk_AbortEnvironmentUpdate() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.AbortEnvironmentUpdateInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.AbortEnvironmentUpdate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CheckDNSAvailability() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.CheckDNSAvailabilityInput{
CNAMEPrefix: aws.String("DNSCnamePrefix"), // Required
}
resp, err := svc.CheckDNSAvailability(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_ComposeEnvironments() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.ComposeEnvironmentsInput{
ApplicationName: aws.String("ApplicationName"),
GroupName: aws.String("GroupName"),
VersionLabels: []*string{
aws.String("VersionLabel"), // Required
// More values...
},
}
resp, err := svc.ComposeEnvironments(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CreateApplication() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.CreateApplicationInput{
ApplicationName: aws.String("ApplicationName"), // Required
Description: aws.String("Description"),
}
resp, err := svc.CreateApplication(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CreateApplicationVersion() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.CreateApplicationVersionInput{
ApplicationName: aws.String("ApplicationName"), // Required
VersionLabel: aws.String("VersionLabel"), // Required
AutoCreateApplication: aws.Bool(true),
Description: aws.String("Description"),
Process: aws.Bool(true),
SourceBundle: &elasticbeanstalk.S3Location{
S3Bucket: aws.String("S3Bucket"),
S3Key: aws.String("S3Key"),
},
}
resp, err := svc.CreateApplicationVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CreateConfigurationTemplate() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.CreateConfigurationTemplateInput{
ApplicationName: aws.String("ApplicationName"), // Required
TemplateName: aws.String("ConfigurationTemplateName"), // Required
Description: aws.String("Description"),
EnvironmentId: aws.String("EnvironmentId"),
OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
Value: aws.String("ConfigurationOptionValue"),
},
// More values...
},
SolutionStackName: aws.String("SolutionStackName"),
SourceConfiguration: &elasticbeanstalk.SourceConfiguration{
ApplicationName: aws.String("ApplicationName"),
TemplateName: aws.String("ConfigurationTemplateName"),
},
}
resp, err := svc.CreateConfigurationTemplate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CreateEnvironment() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.CreateEnvironmentInput{
ApplicationName: aws.String("ApplicationName"), // Required
CNAMEPrefix: aws.String("DNSCnamePrefix"),
Description: aws.String("Description"),
EnvironmentName: aws.String("EnvironmentName"),
GroupName: aws.String("GroupName"),
OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
Value: aws.String("ConfigurationOptionValue"),
},
// More values...
},
OptionsToRemove: []*elasticbeanstalk.OptionSpecification{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
},
// More values...
},
SolutionStackName: aws.String("SolutionStackName"),
Tags: []*elasticbeanstalk.Tag{
{ // Required
Key: aws.String("TagKey"),
Value: aws.String("TagValue"),
},
// More values...
},
TemplateName: aws.String("ConfigurationTemplateName"),
Tier: &elasticbeanstalk.EnvironmentTier{
Name: aws.String("String"),
Type: aws.String("String"),
Version: aws.String("String"),
},
VersionLabel: aws.String("VersionLabel"),
}
resp, err := svc.CreateEnvironment(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_CreateStorageLocation() {
svc := elasticbeanstalk.New(session.New())
var params *elasticbeanstalk.CreateStorageLocationInput
resp, err := svc.CreateStorageLocation(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DeleteApplication() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DeleteApplicationInput{
ApplicationName: aws.String("ApplicationName"), // Required
TerminateEnvByForce: aws.Bool(true),
}
resp, err := svc.DeleteApplication(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DeleteApplicationVersion() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DeleteApplicationVersionInput{
ApplicationName: aws.String("ApplicationName"), // Required
VersionLabel: aws.String("VersionLabel"), // Required
DeleteSourceBundle: aws.Bool(true),
}
resp, err := svc.DeleteApplicationVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DeleteConfigurationTemplate() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DeleteConfigurationTemplateInput{
ApplicationName: aws.String("ApplicationName"), // Required
TemplateName: aws.String("ConfigurationTemplateName"), // Required
}
resp, err := svc.DeleteConfigurationTemplate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DeleteEnvironmentConfiguration() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DeleteEnvironmentConfigurationInput{
ApplicationName: aws.String("ApplicationName"), // Required
EnvironmentName: aws.String("EnvironmentName"), // Required
}
resp, err := svc.DeleteEnvironmentConfiguration(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeApplicationVersions() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeApplicationVersionsInput{
ApplicationName: aws.String("ApplicationName"),
VersionLabels: []*string{
aws.String("VersionLabel"), // Required
// More values...
},
}
resp, err := svc.DescribeApplicationVersions(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeApplications() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeApplicationsInput{
ApplicationNames: []*string{
aws.String("ApplicationName"), // Required
// More values...
},
}
resp, err := svc.DescribeApplications(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeConfigurationOptions() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeConfigurationOptionsInput{
ApplicationName: aws.String("ApplicationName"),
EnvironmentName: aws.String("EnvironmentName"),
Options: []*elasticbeanstalk.OptionSpecification{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
},
// More values...
},
SolutionStackName: aws.String("SolutionStackName"),
TemplateName: aws.String("ConfigurationTemplateName"),
}
resp, err := svc.DescribeConfigurationOptions(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeConfigurationSettings() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeConfigurationSettingsInput{
ApplicationName: aws.String("ApplicationName"), // Required
EnvironmentName: aws.String("EnvironmentName"),
TemplateName: aws.String("ConfigurationTemplateName"),
}
resp, err := svc.DescribeConfigurationSettings(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeEnvironmentHealth() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeEnvironmentHealthInput{
AttributeNames: []*string{
aws.String("EnvironmentHealthAttribute"), // Required
// More values...
},
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.DescribeEnvironmentHealth(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeEnvironmentResources() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeEnvironmentResourcesInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.DescribeEnvironmentResources(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeEnvironments() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeEnvironmentsInput{
ApplicationName: aws.String("ApplicationName"),
EnvironmentIds: []*string{
aws.String("EnvironmentId"), // Required
// More values...
},
EnvironmentNames: []*string{
aws.String("EnvironmentName"), // Required
// More values...
},
IncludeDeleted: aws.Bool(true),
IncludedDeletedBackTo: aws.Time(time.Now()),
VersionLabel: aws.String("VersionLabel"),
}
resp, err := svc.DescribeEnvironments(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeEvents() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeEventsInput{
ApplicationName: aws.String("ApplicationName"),
EndTime: aws.Time(time.Now()),
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
MaxRecords: aws.Int64(1),
NextToken: aws.String("Token"),
RequestId: aws.String("RequestId"),
Severity: aws.String("EventSeverity"),
StartTime: aws.Time(time.Now()),
TemplateName: aws.String("ConfigurationTemplateName"),
VersionLabel: aws.String("VersionLabel"),
}
resp, err := svc.DescribeEvents(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_DescribeInstancesHealth() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.DescribeInstancesHealthInput{
AttributeNames: []*string{
aws.String("InstancesHealthAttribute"), // Required
// More values...
},
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
NextToken: aws.String("NextToken"),
}
resp, err := svc.DescribeInstancesHealth(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_ListAvailableSolutionStacks() {
svc := elasticbeanstalk.New(session.New())
var params *elasticbeanstalk.ListAvailableSolutionStacksInput
resp, err := svc.ListAvailableSolutionStacks(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_RebuildEnvironment() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.RebuildEnvironmentInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.RebuildEnvironment(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_RequestEnvironmentInfo() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.RequestEnvironmentInfoInput{
InfoType: aws.String("EnvironmentInfoType"), // Required
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.RequestEnvironmentInfo(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_RestartAppServer() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.RestartAppServerInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.RestartAppServer(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_RetrieveEnvironmentInfo() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.RetrieveEnvironmentInfoInput{
InfoType: aws.String("EnvironmentInfoType"), // Required
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.RetrieveEnvironmentInfo(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_SwapEnvironmentCNAMEs() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.SwapEnvironmentCNAMEsInput{
DestinationEnvironmentId: aws.String("EnvironmentId"),
DestinationEnvironmentName: aws.String("EnvironmentName"),
SourceEnvironmentId: aws.String("EnvironmentId"),
SourceEnvironmentName: aws.String("EnvironmentName"),
}
resp, err := svc.SwapEnvironmentCNAMEs(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_TerminateEnvironment() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.TerminateEnvironmentInput{
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
ForceTerminate: aws.Bool(true),
TerminateResources: aws.Bool(true),
}
resp, err := svc.TerminateEnvironment(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_UpdateApplication() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.UpdateApplicationInput{
ApplicationName: aws.String("ApplicationName"), // Required
Description: aws.String("Description"),
}
resp, err := svc.UpdateApplication(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_UpdateApplicationVersion() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.UpdateApplicationVersionInput{
ApplicationName: aws.String("ApplicationName"), // Required
VersionLabel: aws.String("VersionLabel"), // Required
Description: aws.String("Description"),
}
resp, err := svc.UpdateApplicationVersion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_UpdateConfigurationTemplate() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.UpdateConfigurationTemplateInput{
ApplicationName: aws.String("ApplicationName"), // Required
TemplateName: aws.String("ConfigurationTemplateName"), // Required
Description: aws.String("Description"),
OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
Value: aws.String("ConfigurationOptionValue"),
},
// More values...
},
OptionsToRemove: []*elasticbeanstalk.OptionSpecification{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
},
// More values...
},
}
resp, err := svc.UpdateConfigurationTemplate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_UpdateEnvironment() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.UpdateEnvironmentInput{
ApplicationName: aws.String("ApplicationName"),
Description: aws.String("Description"),
EnvironmentId: aws.String("EnvironmentId"),
EnvironmentName: aws.String("EnvironmentName"),
GroupName: aws.String("GroupName"),
OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
Value: aws.String("ConfigurationOptionValue"),
},
// More values...
},
OptionsToRemove: []*elasticbeanstalk.OptionSpecification{
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
},
// More values...
},
SolutionStackName: aws.String("SolutionStackName"),
TemplateName: aws.String("ConfigurationTemplateName"),
Tier: &elasticbeanstalk.EnvironmentTier{
Name: aws.String("String"),
Type: aws.String("String"),
Version: aws.String("String"),
},
VersionLabel: aws.String("VersionLabel"),
}
resp, err := svc.UpdateEnvironment(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
func ExampleElasticBeanstalk_ValidateConfigurationSettings() {
svc := elasticbeanstalk.New(session.New())
params := &elasticbeanstalk.ValidateConfigurationSettingsInput{
ApplicationName: aws.String("ApplicationName"), // Required
OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ // Required
{ // Required
Namespace: aws.String("OptionNamespace"),
OptionName: aws.String("ConfigurationOptionName"),
ResourceName: aws.String("ResourceName"),
Value: aws.String("ConfigurationOptionValue"),
},
// More values...
},
EnvironmentName: aws.String("EnvironmentName"),
TemplateName: aws.String("ConfigurationTemplateName"),
}
resp, err := svc.ValidateConfigurationSettings(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}

View File

@ -0,0 +1,106 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
package elasticbeanstalk
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/client/metadata"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/private/protocol/query"
"github.com/aws/aws-sdk-go/private/signer/v4"
)
// This is the AWS Elastic Beanstalk API Reference. This guide provides detailed
// information about AWS Elastic Beanstalk actions, data types, parameters,
// and errors.
//
// AWS Elastic Beanstalk is a tool that makes it easy for you to create, deploy,
// and manage scalable, fault-tolerant applications running on Amazon Web Services
// cloud resources.
//
// For more information about this product, go to the AWS Elastic Beanstalk
// (http://aws.amazon.com/elasticbeanstalk/) details page. The location of the
// latest AWS Elastic Beanstalk WSDL is http://elasticbeanstalk.s3.amazonaws.com/doc/2010-12-01/AWSElasticBeanstalk.wsdl
// (http://elasticbeanstalk.s3.amazonaws.com/doc/2010-12-01/AWSElasticBeanstalk.wsdl).
// To install the Software Development Kits (SDKs), Integrated Development Environment
// (IDE) Toolkits, and command line tools that enable you to access the API,
// go to Tools for Amazon Web Services (https://aws.amazon.com/tools/).
//
// Endpoints
//
// For a list of region-specific endpoints that AWS Elastic Beanstalk supports,
// go to Regions and Endpoints (http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region)
// in the Amazon Web Services Glossary.
//The service client's operations are safe to be used concurrently.
// It is not safe to mutate any of the client's properties though.
type ElasticBeanstalk struct {
*client.Client
}
// Used for custom client initialization logic
var initClient func(*client.Client)
// Used for custom request initialization logic
var initRequest func(*request.Request)
// A ServiceName is the name of the service the client will make API calls to.
const ServiceName = "elasticbeanstalk"
// New creates a new instance of the ElasticBeanstalk client with a session.
// If additional configuration is needed for the client instance use the optional
// aws.Config parameter to add your extra config.
//
// Example:
// // Create a ElasticBeanstalk client from just a session.
// svc := elasticbeanstalk.New(mySession)
//
// // Create a ElasticBeanstalk client with additional configuration
// svc := elasticbeanstalk.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
func New(p client.ConfigProvider, cfgs ...*aws.Config) *ElasticBeanstalk {
c := p.ClientConfig(ServiceName, cfgs...)
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
}
// newClient creates, initializes and returns a new service client instance.
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ElasticBeanstalk {
svc := &ElasticBeanstalk{
Client: client.New(
cfg,
metadata.ClientInfo{
ServiceName: ServiceName,
SigningRegion: signingRegion,
Endpoint: endpoint,
APIVersion: "2010-12-01",
},
handlers,
),
}
// Handlers
svc.Handlers.Sign.PushBack(v4.Sign)
svc.Handlers.Build.PushBack(query.Build)
svc.Handlers.Unmarshal.PushBack(query.Unmarshal)
svc.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)
svc.Handlers.UnmarshalError.PushBack(query.UnmarshalError)
// Run custom client initialization if present
if initClient != nil {
initClient(svc.Client)
}
return svc
}
// newRequest creates a new request for a ElasticBeanstalk operation and runs any
// custom request initialization.
func (c *ElasticBeanstalk) newRequest(op *request.Operation, params, data interface{}) *request.Request {
req := c.NewRequest(op, params, data)
// Run custom request initialization if present
if initRequest != nil {
initRequest(req)
}
return req
}

View File

@ -0,0 +1,39 @@
---
layout: "aws"
page_title: "AWS: aws_elastic_beanstalk_application"
sidebar_current: "docs-aws-resource-elastic-beanstalk-application"
description: |-
Provides an Elastic Beanstalk Application Resource
---
# aws\_elastic\_beanstalk\_<wbr>application
Provides an Elastic Beanstalk Application Resource. Elastic Beanstalk allows
you to deploy and manage applications in the AWS cloud without worrying about
the infrastructure that runs those applications.
This resource creates an application that has one configuration template named
`default`, and no application versions
## Example Usage
```
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
description = "tf-test-desc"
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the application, must be unique within your account
* `description` - (Optional) Short description of the application
## Attributes Reference
The following attributes are exported:
* `name`
* `description`

View File

@ -0,0 +1,59 @@
---
layout: "aws"
page_title: "AWS: aws_elastic_beanstalk_configuration_template"
sidebar_current: "docs-aws-resource-elastic-configuration-template"
description: |-
Provides an Elastic Beanstalk Configuration Template
---
# aws\_elastic\_beanstalk\_<wbr>configuration\_template
Provides an Elastic Beanstalk Configuration Template, which are associated with
a specific application and are used to deploy different versions of the
application with the same configuration settings.
## Example Usage
```
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
description = "tf-test-desc"
}
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"
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) A unique name for this Template.
* `application` (Required) name of the application to associate with this configuration template
* `description` - (Optional) Short description of the Template
* `environment_id` (Optional) The ID of the environment used with this configuration template
* `option_settings`  (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 Template
off of. Example stacks can be found in the [Amazon API documentation][1]
## Attributes Reference
The following attributes are exported:
* `name`
* `application`
* `description`
* `environment_id`
* `option_settings`
* `solution_stack_name`
[1]: http://docs.aws.amazon.com/fr_fr/elasticbeanstalk/latest/dg/concepts.platforms.html

View File

@ -0,0 +1,83 @@
---
layout: "aws"
page_title: "AWS: aws_elastic_beanstalk_environment"
sidebar_current: "docs-aws-resource-elastic-beanstalk-environment"
description: |-
Provides an Elastic Beanstalk Environment Resource
---
# 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
the infrastructure that runs those applications.
Environments are often things such as `development`, `integration`, or
`production`.
## Example Usage
```
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
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"
}
```
## 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
* `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 to use in deployment
* `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
<a id="option-settings"></a>
## Option Settings
The `setting` and `all_settings` mappings support the following format:
* `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
## Attributes Reference
The following attributes are exported:
* `name`
* `description`
* `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
[1]: http://docs.aws.amazon.com/fr_fr/elasticbeanstalk/latest/dg/concepts.platforms.html

View File

@ -132,7 +132,7 @@
</li>
<li<%= sidebar_current(/^docs-aws-resource-(ami|app|autoscaling|ebs|elb|eip|instance|launch|lb|proxy|spot|volume|placement|key-pair)/) %>>
<li<%= sidebar_current(/^docs-aws-resource-(ami|app|autoscaling|ebs|elb|eip|elastic-beanstalk|instance|launch|lb|proxy|spot|volume|placement|key-pair)/) %>>
<a href="#">EC2 Resources</a>
<ul class="nav nav-visible">
@ -184,6 +184,18 @@
<a href="/docs/providers/aws/r/elb.html">aws_elb</a>
</li>
<li<%= sidebar_current("docs-aws-resource-elastic-beanstalk-application") %>>
<a href="/docs/providers/aws/r/elastic_beanstalk_application.html">aws_elastic_beanstalk_application</a>
</li>
<li<%= sidebar_current("docs-aws-resource-elastic-beanstalk-configuration-template") %>>
<a href="/docs/providers/aws/r/elastic_beanstalk_configuration_template.html">aws_elastic_configuation_template</a>
</li>
<li<%= sidebar_current("docs-aws-resource-elastic-beanstalk-environment") %>>
<a href="/docs/providers/aws/r/elastic_beanstalk_environment.html">aws_elastic_beanstalk_environment</a>
</li>
<li<%= sidebar_current("docs-aws-resource-instance") %>>
<a href="/docs/providers/aws/r/instance.html">aws_instance</a>
</li>