Merge branch 'master' into b-aws-iam-role-profile-update
* master: (91 commits) update CHANGELOG update CHANGELOG state/remote: more canonical Go for skip TLS verify update CHANGELOG update CHANGELOG command/apply: flatten multierrors provider/aws: improve iam_policy err msgs acc tests: ensure each resource has a _basic test aws/provider convert _normal tests to _basic go fmt Enpoint type configuration for OpenStack provider Fix page title for aws_elasticache_cluster Update CHANGELOG.md Corrected Frankfurt S3 Website Endpoint fixes #2258 Only run Swift tests when Swift is available Implement OpenStack/Swift remote Minor correction to aws_s3_bucket docs docs: Fix wrong title (aws_autoscaling_notification) provider/aws: clarify scaling timeout error Update CHANGELOG.md ...
This commit is contained in:
commit
35047dbc9f
41
CHANGELOG.md
41
CHANGELOG.md
|
@ -1,5 +1,38 @@
|
|||
## 0.6.0 (Unreleased)
|
||||
|
||||
FEATURES:
|
||||
|
||||
* **New provider: `azure`** [GH-2053]
|
||||
* **New resource: `aws_autoscaling_notification`** [GH-2197]
|
||||
* **New resource: `aws_ecs_cluster`** [GH-1803]
|
||||
* **New resource: `aws_ecs_service`** [GH-1803]
|
||||
* **New resource: `aws_ecs_task_definition`** [GH-1803]
|
||||
* **New remote state backend: `swift`**: You can now store remote state in
|
||||
a OpenStack Swift. [GH-2254]
|
||||
* command/output: support display of module outputs [GH-2102]
|
||||
* core: keys() and values() funcs for map variables [GH-2198]
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* core: HTTP remote state now accepts `skip_cert_verification`
|
||||
option to ignore TLS cert verification. [GH-2214]
|
||||
* provider/aws: ElastiCache Subnet Groups can be updated
|
||||
without destroying first [GH-2191]
|
||||
* provider/docker: `docker_container` has the `privileged`
|
||||
option. [GH-2227]
|
||||
* provider/openstack: allow `OS_AUTH_TOKEN` environment variable
|
||||
to set the openstack `api_key` field [GH-2234]
|
||||
* provider/openstack: Can now configure endpoint type (public, admin,
|
||||
internal) [GH-2262]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
* provider/aws: fix panic when route has no cidr_block [GH-2215]
|
||||
* provider/aws: fix issue causing perpetual diff on ELB listeners
|
||||
when non-lowercase protocol strings were used [GH-2246]
|
||||
* provider/aws: corrected frankfurt S3 website region [GH-2259]
|
||||
* provider/aws: `aws_elasticache_cluster` port is required [GH-2160]
|
||||
|
||||
## 0.5.3 (June 1, 2015)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
@ -140,7 +173,7 @@ IMPROVEMENTS:
|
|||
* **New resource: `google_dns_record_set`**
|
||||
* **Migrate to upstream AWS SDK:** Migrate the AWS provider to
|
||||
[awslabs/aws-sdk-go](https://github.com/awslabs/aws-sdk-go),
|
||||
the offical `awslabs` library. Previously we had forked the library for
|
||||
the official `awslabs` library. Previously we had forked the library for
|
||||
stability while `awslabs` refactored. Now that work has completed, and we've
|
||||
migrated back to the upstream version.
|
||||
* core: Improve error message on diff mismatch [GH-1501]
|
||||
|
@ -168,7 +201,7 @@ IMPROVEMENTS:
|
|||
* provider/aws: `aws_network_acl` improved validation for network ACL ports
|
||||
and protocols [GH-1798] [GH-1808]
|
||||
* provider/aws: `aws_route_table` can target network interfaces [GH-968]
|
||||
* provider/aws: `aws_route_table` can specify propogating VGWs [GH-1516]
|
||||
* provider/aws: `aws_route_table` can specify propagating VGWs [GH-1516]
|
||||
* provider/aws: `aws_route53_record` supports weighted sets [GH-1578]
|
||||
* provider/aws: `aws_route53_zone` exports nameservers [GH-1525]
|
||||
* provider/aws: `aws_s3_bucket` website support [GH-1738]
|
||||
|
@ -325,7 +358,7 @@ FEATURES:
|
|||
* **Math operations** in interpolations. You can now do things like
|
||||
`${count.index+1}`. [GH-1068]
|
||||
* **New AWS SDK:** Move to `aws-sdk-go` (hashicorp/aws-sdk-go),
|
||||
a fork of the offical `awslabs` repo. We forked for stability while
|
||||
a fork of the official `awslabs` repo. We forked for stability while
|
||||
`awslabs` refactored the library, and will move back to the officially
|
||||
supported version in the next release.
|
||||
|
||||
|
@ -354,7 +387,7 @@ IMPROVEMENTS:
|
|||
* providers/aws: Improve dependency violation error handling, when deleting
|
||||
Internet Gateways or Auto Scaling groups [GH-1325].
|
||||
* provider/aws: Add non-destructive updates to AWS RDS. You can now upgrade
|
||||
`egine_version`, `parameter_group_name`, and `multi_az` without forcing
|
||||
`engine_version`, `parameter_group_name`, and `multi_az` without forcing
|
||||
a new database to be created.[GH-1341]
|
||||
* providers/aws: Full support for block device mappings on instances and
|
||||
launch configurations [GH-1045, GH-1364]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/builtin/providers/azure"
|
||||
"github.com/hashicorp/terraform/plugin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
plugin.Serve(&plugin.ServeOpts{
|
||||
ProviderFunc: azure.Provider,
|
||||
})
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package main
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -7,19 +7,20 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/multierror"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/credentials"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/awslabs/aws-sdk-go/service/kinesis"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
"github.com/awslabs/aws-sdk-go/service/sns"
|
||||
"github.com/awslabs/aws-sdk-go/service/sqs"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"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/elb"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/service/kinesis"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/aws/aws-sdk-go/service/sns"
|
||||
"github.com/aws/aws-sdk-go/service/sqs"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -35,6 +36,7 @@ type Config struct {
|
|||
|
||||
type AWSClient struct {
|
||||
ec2conn *ec2.EC2
|
||||
ecsconn *ecs.ECS
|
||||
elbconn *elb.ELB
|
||||
autoscalingconn *autoscaling.AutoScaling
|
||||
s3conn *s3.S3
|
||||
|
@ -116,6 +118,9 @@ func (c *Config) Client() (interface{}, error) {
|
|||
log.Println("[INFO] Initializing EC2 Connection")
|
||||
client.ec2conn = ec2.New(awsConfig)
|
||||
|
||||
log.Println("[INFO] Initializing ECS Connection")
|
||||
client.ecsconn = ecs.New(awsConfig)
|
||||
|
||||
// aws-sdk-go uses v4 for signing requests, which requires all global
|
||||
// endpoints to use 'us-east-1'.
|
||||
// See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"net"
|
||||
"strconv"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
)
|
||||
|
||||
func expandNetworkAclEntries(configured []interface{}, entryType string) ([]*ec2.NetworkACLEntry, error) {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
)
|
||||
|
||||
func Test_expandNetworkACLEntry(t *testing.T) {
|
||||
|
|
|
@ -85,12 +85,16 @@ func Provider() terraform.ResourceProvider {
|
|||
ResourcesMap: map[string]*schema.Resource{
|
||||
"aws_app_cookie_stickiness_policy": resourceAwsAppCookieStickinessPolicy(),
|
||||
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
|
||||
"aws_autoscaling_notification": resourceAwsAutoscalingNotification(),
|
||||
"aws_customer_gateway": resourceAwsCustomerGateway(),
|
||||
"aws_db_instance": resourceAwsDbInstance(),
|
||||
"aws_db_parameter_group": resourceAwsDbParameterGroup(),
|
||||
"aws_db_security_group": resourceAwsDbSecurityGroup(),
|
||||
"aws_db_subnet_group": resourceAwsDbSubnetGroup(),
|
||||
"aws_ebs_volume": resourceAwsEbsVolume(),
|
||||
"aws_ecs_cluster": resourceAwsEcsCluster(),
|
||||
"aws_ecs_service": resourceAwsEcsService(),
|
||||
"aws_ecs_task_definition": resourceAwsEcsTaskDefinition(),
|
||||
"aws_eip": resourceAwsEip(),
|
||||
"aws_elasticache_cluster": resourceAwsElasticacheCluster(),
|
||||
"aws_elasticache_security_group": resourceAwsElasticacheSecurityGroup(),
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSAppCookieStickinessPolicy(t *testing.T) {
|
||||
func TestAccAWSAppCookieStickinessPolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
)
|
||||
|
||||
func resourceAwsAutoscalingGroup() *schema.Resource {
|
||||
|
@ -462,7 +462,7 @@ func waitForASGCapacity(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("Still need to wait for more healthy instances.")
|
||||
return fmt.Errorf("Still need to wait for more healthy instances. This could mean instances failed to launch. See Scaling History for more information.")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceAwsAutoscalingNotification() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsAutoscalingNotificationCreate,
|
||||
Read: resourceAwsAutoscalingNotificationRead,
|
||||
Update: resourceAwsAutoscalingNotificationUpdate,
|
||||
Delete: resourceAwsAutoscalingNotificationDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"topic_arn": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"group_names": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"notifications": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAwsAutoscalingNotificationCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).autoscalingconn
|
||||
gl := convertSetToList(d.Get("group_names").(*schema.Set))
|
||||
nl := convertSetToList(d.Get("notifications").(*schema.Set))
|
||||
|
||||
topic := d.Get("topic_arn").(string)
|
||||
if err := addNotificationConfigToGroupsWithTopic(conn, gl, nl, topic); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// ARNs are unique, and these notifications are per ARN, so we re-use the ARN
|
||||
// here as the ID
|
||||
d.SetId(topic)
|
||||
return resourceAwsAutoscalingNotificationRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsAutoscalingNotificationRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).autoscalingconn
|
||||
gl := convertSetToList(d.Get("group_names").(*schema.Set))
|
||||
|
||||
opts := &autoscaling.DescribeNotificationConfigurationsInput{
|
||||
AutoScalingGroupNames: gl,
|
||||
}
|
||||
|
||||
resp, err := conn.DescribeNotificationConfigurations(opts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error describing notifications")
|
||||
}
|
||||
|
||||
topic := d.Get("topic_arn").(string)
|
||||
// Grab all applicable notifcation configurations for this Topic.
|
||||
// Each NotificationType will have a record, so 1 Group with 3 Types results
|
||||
// in 3 records, all with the same Group name
|
||||
gRaw := make(map[string]bool)
|
||||
nRaw := make(map[string]bool)
|
||||
for _, n := range resp.NotificationConfigurations {
|
||||
if *n.TopicARN == topic {
|
||||
gRaw[*n.AutoScalingGroupName] = true
|
||||
nRaw[*n.NotificationType] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the keys here as the list of Groups
|
||||
var gList []string
|
||||
for k, _ := range gRaw {
|
||||
gList = append(gList, k)
|
||||
}
|
||||
|
||||
// Grab the keys here as the list of Types
|
||||
var nList []string
|
||||
for k, _ := range nRaw {
|
||||
nList = append(nList, k)
|
||||
}
|
||||
|
||||
if err := d.Set("group_names", gList); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("notifications", nList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsAutoscalingNotificationUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).autoscalingconn
|
||||
|
||||
// Notifications API call is a PUT, so we don't need to diff the list, just
|
||||
// push whatever it is and AWS sorts it out
|
||||
nl := convertSetToList(d.Get("notifications").(*schema.Set))
|
||||
|
||||
o, n := d.GetChange("group_names")
|
||||
if o == nil {
|
||||
o = new(schema.Set)
|
||||
}
|
||||
if n == nil {
|
||||
n = new(schema.Set)
|
||||
}
|
||||
|
||||
os := o.(*schema.Set)
|
||||
ns := n.(*schema.Set)
|
||||
remove := convertSetToList(os.Difference(ns))
|
||||
add := convertSetToList(ns.Difference(os))
|
||||
|
||||
topic := d.Get("topic_arn").(string)
|
||||
|
||||
if err := removeNotificationConfigToGroupsWithTopic(conn, remove, topic); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var update []*string
|
||||
if d.HasChange("notifications") {
|
||||
update = convertSetToList(d.Get("group_names").(*schema.Set))
|
||||
} else {
|
||||
update = add
|
||||
}
|
||||
|
||||
if err := addNotificationConfigToGroupsWithTopic(conn, update, nl, topic); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return resourceAwsAutoscalingNotificationRead(d, meta)
|
||||
}
|
||||
|
||||
func addNotificationConfigToGroupsWithTopic(conn *autoscaling.AutoScaling, groups []*string, nl []*string, topic string) error {
|
||||
for _, a := range groups {
|
||||
opts := &autoscaling.PutNotificationConfigurationInput{
|
||||
AutoScalingGroupName: a,
|
||||
NotificationTypes: nl,
|
||||
TopicARN: aws.String(topic),
|
||||
}
|
||||
|
||||
_, err := conn.PutNotificationConfiguration(opts)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.Error); ok {
|
||||
return fmt.Errorf("[WARN] Error creating Autoscaling Group Notification for Group %s, error: \"%s\", code: \"%s\"", *a, awsErr.Message(), awsErr.Code())
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeNotificationConfigToGroupsWithTopic(conn *autoscaling.AutoScaling, groups []*string, topic string) error {
|
||||
for _, r := range groups {
|
||||
opts := &autoscaling.DeleteNotificationConfigurationInput{
|
||||
AutoScalingGroupName: r,
|
||||
TopicARN: aws.String(topic),
|
||||
}
|
||||
|
||||
_, err := conn.DeleteNotificationConfiguration(opts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("[WARN] Error deleting notification configuration for ASG \"%s\", Topic ARN \"%s\"", *r, topic)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsAutoscalingNotificationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).autoscalingconn
|
||||
gl := convertSetToList(d.Get("group_names").(*schema.Set))
|
||||
|
||||
topic := d.Get("topic_arn").(string)
|
||||
if err := removeNotificationConfigToGroupsWithTopic(conn, gl, topic); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertSetToList(s *schema.Set) (nl []*string) {
|
||||
l := s.List()
|
||||
for _, n := range l {
|
||||
nl = append(nl, aws.String(n.(string)))
|
||||
}
|
||||
|
||||
return nl
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccASGNotification_basic(t *testing.T) {
|
||||
var asgn autoscaling.DescribeNotificationConfigurationsOutput
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckASGNDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test"}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccASGNotification_update(t *testing.T) {
|
||||
var asgn autoscaling.DescribeNotificationConfigurationsOutput
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckASGNDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test"}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccASGNotificationConfig_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckASGNotificationExists("aws_autoscaling_notification.example", []string{"foobar1-terraform-test", "barfoo-terraform-test"}, &asgn),
|
||||
testAccCheckAWSASGNotificationAttributes("aws_autoscaling_notification.example", &asgn),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckASGNotificationExists(n string, groups []string, asgn *autoscaling.DescribeNotificationConfigurationsOutput) 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("No ASG Notification ID is set")
|
||||
}
|
||||
|
||||
var gl []*string
|
||||
for _, g := range groups {
|
||||
gl = append(gl, aws.String(g))
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).autoscalingconn
|
||||
opts := &autoscaling.DescribeNotificationConfigurationsInput{
|
||||
AutoScalingGroupNames: gl,
|
||||
}
|
||||
|
||||
resp, err := conn.DescribeNotificationConfigurations(opts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error describing notifications")
|
||||
}
|
||||
|
||||
*asgn = *resp
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckASGNDestroy(s *terraform.State) error {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_autoscaling_notification" {
|
||||
continue
|
||||
}
|
||||
|
||||
groups := []*string{aws.String("foobar1-terraform-test")}
|
||||
conn := testAccProvider.Meta().(*AWSClient).autoscalingconn
|
||||
opts := &autoscaling.DescribeNotificationConfigurationsInput{
|
||||
AutoScalingGroupNames: groups,
|
||||
}
|
||||
|
||||
resp, err := conn.DescribeNotificationConfigurations(opts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error describing notifications")
|
||||
}
|
||||
|
||||
if len(resp.NotificationConfigurations) != 0 {
|
||||
fmt.Errorf("Error finding notification descriptions")
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckAWSASGNotificationAttributes(n string, asgn *autoscaling.DescribeNotificationConfigurationsOutput) 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("No ASG Notification ID is set")
|
||||
}
|
||||
|
||||
if len(asgn.NotificationConfigurations) == 0 {
|
||||
return fmt.Errorf("Error: no ASG Notifications found")
|
||||
}
|
||||
|
||||
// build a unique list of groups, notification types
|
||||
gRaw := make(map[string]bool)
|
||||
nRaw := make(map[string]bool)
|
||||
for _, n := range asgn.NotificationConfigurations {
|
||||
if *n.TopicARN == rs.Primary.Attributes["topic_arn"] {
|
||||
gRaw[*n.AutoScalingGroupName] = true
|
||||
nRaw[*n.NotificationType] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the keys here as the list of Groups
|
||||
var gList []string
|
||||
for k, _ := range gRaw {
|
||||
gList = append(gList, k)
|
||||
}
|
||||
|
||||
// Grab the keys here as the list of Types
|
||||
var nList []string
|
||||
for k, _ := range nRaw {
|
||||
nList = append(nList, k)
|
||||
}
|
||||
|
||||
typeCount, _ := strconv.Atoi(rs.Primary.Attributes["notifications.#"])
|
||||
|
||||
if len(nList) != typeCount {
|
||||
return fmt.Errorf("Error: Bad ASG Notification count, expected (%d), got (%d)", typeCount, len(nList))
|
||||
}
|
||||
|
||||
groupCount, _ := strconv.Atoi(rs.Primary.Attributes["group_names.#"])
|
||||
|
||||
if len(gList) != groupCount {
|
||||
return fmt.Errorf("Error: Bad ASG Group count, expected (%d), got (%d)", typeCount, len(gList))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccASGNotificationConfig_basic = `
|
||||
resource "aws_sns_topic" "topic_example" {
|
||||
name = "user-updates-topic"
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
name = "foobarautoscaling-terraform-test"
|
||||
image_id = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "bar" {
|
||||
availability_zones = ["us-west-2a"]
|
||||
name = "foobar1-terraform-test"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 100
|
||||
health_check_type = "ELB"
|
||||
desired_capacity = 1
|
||||
force_delete = true
|
||||
termination_policies = ["OldestInstance"]
|
||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_notification" "example" {
|
||||
group_names = ["${aws_autoscaling_group.bar.name}"]
|
||||
notifications = [
|
||||
"autoscaling:EC2_INSTANCE_LAUNCH",
|
||||
"autoscaling:EC2_INSTANCE_TERMINATE",
|
||||
]
|
||||
topic_arn = "${aws_sns_topic.topic_example.arn}"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccASGNotificationConfig_update = `
|
||||
resource "aws_sns_topic" "user_updates" {
|
||||
name = "user-updates-topic"
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "foobar" {
|
||||
name = "foobarautoscaling-terraform-test"
|
||||
image_id = "ami-21f78e11"
|
||||
instance_type = "t1.micro"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "bar" {
|
||||
availability_zones = ["us-west-2a"]
|
||||
name = "foobar1-terraform-test"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 100
|
||||
health_check_type = "ELB"
|
||||
desired_capacity = 1
|
||||
force_delete = true
|
||||
termination_policies = ["OldestInstance"]
|
||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "foo" {
|
||||
availability_zones = ["us-west-2b"]
|
||||
name = "barfoo-terraform-test"
|
||||
max_size = 1
|
||||
min_size = 1
|
||||
health_check_grace_period = 200
|
||||
health_check_type = "ELB"
|
||||
desired_capacity = 1
|
||||
force_delete = true
|
||||
termination_policies = ["OldestInstance"]
|
||||
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_notification" "example" {
|
||||
group_names = [
|
||||
"${aws_autoscaling_group.bar.name}",
|
||||
"${aws_autoscaling_group.foo.name}",
|
||||
]
|
||||
notifications = [
|
||||
"autoscaling:EC2_INSTANCE_LAUNCH",
|
||||
"autoscaling:EC2_INSTANCE_TERMINATE",
|
||||
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR"
|
||||
]
|
||||
topic_arn = "${aws_sns_topic.user_updates.arn}"
|
||||
}`
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccCustomerGateway(t *testing.T) {
|
||||
func TestAccCustomerGateway_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -9,12 +9,12 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func TestAccAWSDBInstance(t *testing.T) {
|
||||
func TestAccAWSDBInstance_basic(t *testing.T) {
|
||||
var v rds.DBInstance
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func resourceAwsDbParameterGroup() *schema.Resource {
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSDBParameterGroup(t *testing.T) {
|
||||
func TestAccAWSDBParameterGroup_basic(t *testing.T) {
|
||||
var v rds.DBParameterGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/multierror"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSDBSecurityGroup(t *testing.T) {
|
||||
func TestAccAWSDBSecurityGroup_basic(t *testing.T) {
|
||||
var v rds.DBSecurityGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/rds"
|
||||
)
|
||||
|
||||
func TestAccAWSDBSubnetGroup(t *testing.T) {
|
||||
func TestAccAWSDBSubnetGroup_basic(t *testing.T) {
|
||||
var v rds.DBSubnetGroup
|
||||
|
||||
testCheck := func(*terraform.State) error {
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSEBSVolume(t *testing.T) {
|
||||
func TestAccAWSEBSVolume_basic(t *testing.T) {
|
||||
var v ec2.Volume
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceAwsEcsCluster() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsEcsClusterCreate,
|
||||
Read: resourceAwsEcsClusterRead,
|
||||
Delete: resourceAwsEcsClusterDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAwsEcsClusterCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
clusterName := d.Get("name").(string)
|
||||
log.Printf("[DEBUG] Creating ECS cluster %s", clusterName)
|
||||
|
||||
out, err := conn.CreateCluster(&ecs.CreateClusterInput{
|
||||
ClusterName: aws.String(clusterName),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("[DEBUG] ECS cluster %s created", *out.Cluster.ClusterARN)
|
||||
|
||||
d.SetId(*out.Cluster.ClusterARN)
|
||||
d.Set("name", *out.Cluster.ClusterName)
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsClusterRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
clusterName := d.Get("name").(string)
|
||||
log.Printf("[DEBUG] Reading ECS cluster %s", clusterName)
|
||||
out, err := conn.DescribeClusters(&ecs.DescribeClustersInput{
|
||||
Clusters: []*string{aws.String(clusterName)},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("[DEBUG] Received ECS clusters: %#v", out.Clusters)
|
||||
|
||||
d.SetId(*out.Clusters[0].ClusterARN)
|
||||
d.Set("name", *out.Clusters[0].ClusterName)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsClusterDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
log.Printf("[DEBUG] Deleting ECS cluster %s", d.Id())
|
||||
|
||||
// TODO: Handle ClientException: The Cluster cannot be deleted while Container Instances are active.
|
||||
// TODO: Handle ClientException: The Cluster cannot be deleted while Services are active.
|
||||
|
||||
out, err := conn.DeleteCluster(&ecs.DeleteClusterInput{
|
||||
Cluster: aws.String(d.Id()),
|
||||
})
|
||||
|
||||
log.Printf("[DEBUG] ECS cluster %s deleted: %#v", d.Id(), out)
|
||||
|
||||
return err
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSEcsCluster_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSEcsClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsCluster,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsClusterExists("aws_ecs_cluster.foo"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsClusterDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ecsconn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_ecs_cluster" {
|
||||
continue
|
||||
}
|
||||
|
||||
out, err := conn.DescribeClusters(&ecs.DescribeClustersInput{
|
||||
Clusters: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
if len(out.Clusters) != 0 {
|
||||
return fmt.Errorf("ECS cluster still exists:\n%#v", out.Clusters)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsClusterExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
_, ok := s.RootModule().Resources[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var testAccAWSEcsCluster = `
|
||||
resource "aws_ecs_cluster" "foo" {
|
||||
name = "red-grapes"
|
||||
}
|
||||
`
|
|
@ -0,0 +1,316 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
var taskDefinitionRE = regexp.MustCompile("^([a-zA-Z0-9_-]+):([0-9]+)$")
|
||||
|
||||
func resourceAwsEcsService() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsEcsServiceCreate,
|
||||
Read: resourceAwsEcsServiceRead,
|
||||
Update: resourceAwsEcsServiceUpdate,
|
||||
Delete: resourceAwsEcsServiceDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"cluster": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"task_definition": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
"desired_count": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"iam_role": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"load_balancer": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"elb_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
"container_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
"container_port": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAwsEcsLoadBalancerHash,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
input := ecs.CreateServiceInput{
|
||||
ServiceName: aws.String(d.Get("name").(string)),
|
||||
TaskDefinition: aws.String(d.Get("task_definition").(string)),
|
||||
DesiredCount: aws.Long(int64(d.Get("desired_count").(int))),
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("cluster"); ok {
|
||||
input.Cluster = aws.String(v.(string))
|
||||
}
|
||||
|
||||
loadBalancers := expandEcsLoadBalancers(d.Get("load_balancer").(*schema.Set).List())
|
||||
if len(loadBalancers) > 0 {
|
||||
log.Printf("[DEBUG] Adding ECS load balancers: %#v", loadBalancers)
|
||||
input.LoadBalancers = loadBalancers
|
||||
}
|
||||
if v, ok := d.GetOk("iam_role"); ok {
|
||||
input.Role = aws.String(v.(string))
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating ECS service: %#v", input)
|
||||
out, err := conn.CreateService(&input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
service := *out.Service
|
||||
|
||||
log.Printf("[DEBUG] ECS service created: %s", *service.ServiceARN)
|
||||
d.SetId(*service.ServiceARN)
|
||||
d.Set("cluster", *service.ClusterARN)
|
||||
|
||||
return resourceAwsEcsServiceUpdate(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
log.Printf("[DEBUG] Reading ECS service %s", d.Id())
|
||||
input := ecs.DescribeServicesInput{
|
||||
Services: []*string{aws.String(d.Id())},
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
}
|
||||
|
||||
out, err := conn.DescribeServices(&input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
service := out.Services[0]
|
||||
log.Printf("[DEBUG] Received ECS service %#v", service)
|
||||
|
||||
d.SetId(*service.ServiceARN)
|
||||
d.Set("name", *service.ServiceName)
|
||||
|
||||
// Save task definition in the same format
|
||||
if strings.HasPrefix(d.Get("task_definition").(string), "arn:aws:ecs:") {
|
||||
d.Set("task_definition", *service.TaskDefinition)
|
||||
} else {
|
||||
taskDefinition := buildFamilyAndRevisionFromARN(*service.TaskDefinition)
|
||||
d.Set("task_definition", taskDefinition)
|
||||
}
|
||||
|
||||
d.Set("desired_count", *service.DesiredCount)
|
||||
d.Set("cluster", *service.ClusterARN)
|
||||
|
||||
if service.RoleARN != nil {
|
||||
d.Set("iam_role", *service.RoleARN)
|
||||
}
|
||||
|
||||
if service.LoadBalancers != nil {
|
||||
d.Set("load_balancers", flattenEcsLoadBalancers(service.LoadBalancers))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsServiceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
log.Printf("[DEBUG] Updating ECS service %s", d.Id())
|
||||
input := ecs.UpdateServiceInput{
|
||||
Service: aws.String(d.Id()),
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
}
|
||||
|
||||
if d.HasChange("desired_count") {
|
||||
_, n := d.GetChange("desired_count")
|
||||
input.DesiredCount = aws.Long(int64(n.(int)))
|
||||
}
|
||||
if d.HasChange("task_definition") {
|
||||
_, n := d.GetChange("task_definition")
|
||||
input.TaskDefinition = aws.String(n.(string))
|
||||
}
|
||||
|
||||
out, err := conn.UpdateService(&input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
service := out.Service
|
||||
log.Printf("[DEBUG] Updated ECS service %#v", service)
|
||||
|
||||
return resourceAwsEcsServiceRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
// Check if it's not already gone
|
||||
resp, err := conn.DescribeServices(&ecs.DescribeServicesInput{
|
||||
Services: []*string{aws.String(d.Id())},
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("[DEBUG] ECS service %s is currently %s", d.Id(), *resp.Services[0].Status)
|
||||
|
||||
if *resp.Services[0].Status == "INACTIVE" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Drain the ECS service
|
||||
if *resp.Services[0].Status != "DRAINING" {
|
||||
log.Printf("[DEBUG] Draining ECS service %s", d.Id())
|
||||
_, err = conn.UpdateService(&ecs.UpdateServiceInput{
|
||||
Service: aws.String(d.Id()),
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
DesiredCount: aws.Long(int64(0)),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
input := ecs.DeleteServiceInput{
|
||||
Service: aws.String(d.Id()),
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Deleting ECS service %#v", input)
|
||||
out, err := conn.DeleteService(&input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait until it's deleted
|
||||
wait := resource.StateChangeConf{
|
||||
Pending: []string{"DRAINING"},
|
||||
Target: "INACTIVE",
|
||||
Timeout: 5 * time.Minute,
|
||||
MinTimeout: 1 * time.Second,
|
||||
Refresh: func() (interface{}, string, error) {
|
||||
log.Printf("[DEBUG] Checking if ECS service %s is INACTIVE", d.Id())
|
||||
resp, err := conn.DescribeServices(&ecs.DescribeServicesInput{
|
||||
Services: []*string{aws.String(d.Id())},
|
||||
Cluster: aws.String(d.Get("cluster").(string)),
|
||||
})
|
||||
if err != nil {
|
||||
return resp, "FAILED", err
|
||||
}
|
||||
|
||||
return resp, *resp.Services[0].Status, nil
|
||||
},
|
||||
}
|
||||
|
||||
_, err = wait.WaitForState()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] ECS service %s deleted.", *out.Service.ServiceARN)
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsLoadBalancerHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["elb_name"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["container_name"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["container_port"].(int)))
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func buildFamilyAndRevisionFromARN(arn string) string {
|
||||
return strings.Split(arn, "/")[1]
|
||||
}
|
||||
|
||||
func buildTaskDefinitionARN(taskDefinition string, meta interface{}) (string, error) {
|
||||
// If it's already an ARN, just return it
|
||||
if strings.HasPrefix(taskDefinition, "arn:aws:ecs:") {
|
||||
return taskDefinition, nil
|
||||
}
|
||||
|
||||
// Parse out family & revision
|
||||
family, revision, err := parseTaskDefinition(taskDefinition)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
iamconn := meta.(*AWSClient).iamconn
|
||||
region := meta.(*AWSClient).region
|
||||
|
||||
// An zero value GetUserInput{} defers to the currently logged in user
|
||||
resp, err := iamconn.GetUser(&iam.GetUserInput{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("GetUser ERROR: %#v", err)
|
||||
}
|
||||
|
||||
// arn:aws:iam::0123456789:user/username
|
||||
userARN := *resp.User.ARN
|
||||
accountID := strings.Split(userARN, ":")[4]
|
||||
|
||||
// arn:aws:ecs:us-west-2:01234567890:task-definition/mongodb:3
|
||||
arn := fmt.Sprintf("arn:aws:ecs:%s:%s:task-definition/%s:%s",
|
||||
region, accountID, family, revision)
|
||||
log.Printf("[DEBUG] Built task definition ARN: %s", arn)
|
||||
return arn, nil
|
||||
}
|
||||
|
||||
func parseTaskDefinition(taskDefinition string) (string, string, error) {
|
||||
matches := taskDefinitionRE.FindAllStringSubmatch(taskDefinition, 2)
|
||||
|
||||
if len(matches) == 0 || len(matches[0]) != 3 {
|
||||
return "", "", fmt.Errorf(
|
||||
"Invalid task definition format, family:rev or ARN expected (%#v)",
|
||||
taskDefinition)
|
||||
}
|
||||
|
||||
return matches[0][1], matches[0][2], nil
|
||||
}
|
|
@ -0,0 +1,276 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestParseTaskDefinition(t *testing.T) {
|
||||
cases := map[string]map[string]interface{}{
|
||||
"invalid": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"invalidWithColon:": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"1234": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"invalid:aaa": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"invalid=family:1": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"invalid:name:1": map[string]interface{}{
|
||||
"family": "",
|
||||
"revision": "",
|
||||
"isValid": false,
|
||||
},
|
||||
"valid:1": map[string]interface{}{
|
||||
"family": "valid",
|
||||
"revision": "1",
|
||||
"isValid": true,
|
||||
},
|
||||
"abc12-def:54": map[string]interface{}{
|
||||
"family": "abc12-def",
|
||||
"revision": "54",
|
||||
"isValid": true,
|
||||
},
|
||||
"lorem_ip-sum:123": map[string]interface{}{
|
||||
"family": "lorem_ip-sum",
|
||||
"revision": "123",
|
||||
"isValid": true,
|
||||
},
|
||||
"lorem-ipsum:1": map[string]interface{}{
|
||||
"family": "lorem-ipsum",
|
||||
"revision": "1",
|
||||
"isValid": true,
|
||||
},
|
||||
}
|
||||
|
||||
for input, expectedOutput := range cases {
|
||||
family, revision, err := parseTaskDefinition(input)
|
||||
isValid := expectedOutput["isValid"].(bool)
|
||||
if !isValid && err == nil {
|
||||
t.Fatalf("Task definition %s should fail", input)
|
||||
}
|
||||
|
||||
expectedFamily := expectedOutput["family"].(string)
|
||||
if family != expectedFamily {
|
||||
t.Fatalf("Unexpected family (%#v) for task definition %s\n%#v", family, input, err)
|
||||
}
|
||||
expectedRevision := expectedOutput["revision"].(string)
|
||||
if revision != expectedRevision {
|
||||
t.Fatalf("Unexpected revision (%#v) for task definition %s\n%#v", revision, input, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccAWSEcsServiceWithARN(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSEcsServiceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsService,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsServiceModified,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSEcsServiceWithFamilyAndRevision(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSEcsServiceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsServiceWithFamilyAndRevision,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.jenkins"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsServiceWithFamilyAndRevisionModified,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.jenkins"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsServiceDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ecsconn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_ecs_service" {
|
||||
continue
|
||||
}
|
||||
|
||||
out, err := conn.DescribeServices(&ecs.DescribeServicesInput{
|
||||
Services: []*string{aws.String(rs.Primary.ID)},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
if len(out.Services) > 0 {
|
||||
return fmt.Errorf("ECS service still exists:\n%#v", out.Services)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsServiceExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
_, ok := s.RootModule().Resources[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var testAccAWSEcsService = `
|
||||
resource "aws_ecs_cluster" "default" {
|
||||
name = "terraformecstest1"
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "mongo" {
|
||||
family = "mongodb"
|
||||
container_definitions = <<DEFINITION
|
||||
[
|
||||
{
|
||||
"cpu": 128,
|
||||
"essential": true,
|
||||
"image": "mongo:latest",
|
||||
"memory": 128,
|
||||
"name": "mongodb"
|
||||
}
|
||||
]
|
||||
DEFINITION
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "mongo" {
|
||||
name = "mongodb"
|
||||
cluster = "${aws_ecs_cluster.default.id}"
|
||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||
desired_count = 1
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAWSEcsServiceModified = `
|
||||
resource "aws_ecs_cluster" "default" {
|
||||
name = "terraformecstest1"
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "mongo" {
|
||||
family = "mongodb"
|
||||
container_definitions = <<DEFINITION
|
||||
[
|
||||
{
|
||||
"cpu": 128,
|
||||
"essential": true,
|
||||
"image": "mongo:latest",
|
||||
"memory": 128,
|
||||
"name": "mongodb"
|
||||
}
|
||||
]
|
||||
DEFINITION
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "mongo" {
|
||||
name = "mongodb"
|
||||
cluster = "${aws_ecs_cluster.default.id}"
|
||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||
desired_count = 2
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAWSEcsServiceWithFamilyAndRevision = `
|
||||
resource "aws_ecs_cluster" "default" {
|
||||
name = "terraformecstest2"
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "jenkins" {
|
||||
family = "jenkins"
|
||||
container_definitions = <<DEFINITION
|
||||
[
|
||||
{
|
||||
"cpu": 128,
|
||||
"essential": true,
|
||||
"image": "jenkins:latest",
|
||||
"memory": 128,
|
||||
"name": "jenkins"
|
||||
}
|
||||
]
|
||||
DEFINITION
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "jenkins" {
|
||||
name = "jenkins"
|
||||
cluster = "${aws_ecs_cluster.default.id}"
|
||||
task_definition = "${aws_ecs_task_definition.jenkins.family}:${aws_ecs_task_definition.jenkins.revision}"
|
||||
desired_count = 1
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAWSEcsServiceWithFamilyAndRevisionModified = `
|
||||
resource "aws_ecs_cluster" "default" {
|
||||
name = "terraformecstest2"
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "jenkins" {
|
||||
family = "jenkins"
|
||||
container_definitions = <<DEFINITION
|
||||
[
|
||||
{
|
||||
"cpu": 128,
|
||||
"essential": true,
|
||||
"image": "jenkins:latest",
|
||||
"memory": 128,
|
||||
"name": "jenkins"
|
||||
}
|
||||
]
|
||||
DEFINITION
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "jenkins" {
|
||||
name = "jenkins"
|
||||
cluster = "${aws_ecs_cluster.default.id}"
|
||||
task_definition = "${aws_ecs_task_definition.jenkins.family}:${aws_ecs_task_definition.jenkins.revision}"
|
||||
desired_count = 1
|
||||
}
|
||||
`
|
|
@ -0,0 +1,158 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceAwsEcsTaskDefinition() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsEcsTaskDefinitionCreate,
|
||||
Read: resourceAwsEcsTaskDefinitionRead,
|
||||
Update: resourceAwsEcsTaskDefinitionUpdate,
|
||||
Delete: resourceAwsEcsTaskDefinitionDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"arn": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"family": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"revision": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"container_definitions": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: func(v interface{}) string {
|
||||
hash := sha1.Sum([]byte(v.(string)))
|
||||
return hex.EncodeToString(hash[:])
|
||||
},
|
||||
},
|
||||
|
||||
"volume": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
|
||||
"host_path": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAwsEcsTaskDefinitionVolumeHash,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
rawDefinitions := d.Get("container_definitions").(string)
|
||||
definitions, err := expandEcsContainerDefinitions(rawDefinitions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input := ecs.RegisterTaskDefinitionInput{
|
||||
ContainerDefinitions: definitions,
|
||||
Family: aws.String(d.Get("family").(string)),
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("volume"); ok {
|
||||
volumes, err := expandEcsVolumes(v.(*schema.Set).List())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
input.Volumes = volumes
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Registering ECS task definition: %#v", input)
|
||||
out, err := conn.RegisterTaskDefinition(&input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
taskDefinition := *out.TaskDefinition
|
||||
|
||||
log.Printf("[DEBUG] ECS task definition registered: %#v (rev. %d)",
|
||||
*taskDefinition.TaskDefinitionARN, *taskDefinition.Revision)
|
||||
|
||||
d.SetId(*taskDefinition.Family)
|
||||
d.Set("arn", *taskDefinition.TaskDefinitionARN)
|
||||
|
||||
return resourceAwsEcsTaskDefinitionRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsEcsTaskDefinitionRead(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
log.Printf("[DEBUG] Reading task definition %s", d.Id())
|
||||
out, err := conn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{
|
||||
TaskDefinition: aws.String(d.Get("arn").(string)),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("[DEBUG] Received task definition %#v", out)
|
||||
|
||||
taskDefinition := out.TaskDefinition
|
||||
|
||||
d.SetId(*taskDefinition.Family)
|
||||
d.Set("arn", *taskDefinition.TaskDefinitionARN)
|
||||
d.Set("family", *taskDefinition.Family)
|
||||
d.Set("revision", *taskDefinition.Revision)
|
||||
d.Set("container_definitions", taskDefinition.ContainerDefinitions)
|
||||
d.Set("volumes", flattenEcsVolumes(taskDefinition.Volumes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsTaskDefinitionUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
return resourceAwsEcsTaskDefinitionCreate(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsEcsTaskDefinitionDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).ecsconn
|
||||
|
||||
// NOT YET IMPLEMENTED o_O
|
||||
_, err := conn.DeregisterTaskDefinition(&ecs.DeregisterTaskDefinitionInput{
|
||||
TaskDefinition: aws.String(d.Id()),
|
||||
})
|
||||
|
||||
log.Printf("[DEBUG] Deregistering task definition %s returned %#v", d.Id(), err)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsEcsTaskDefinitionVolumeHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["host_path"].(string)))
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ecs"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSEcsTaskDefinition_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSEcsTaskDefinition,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.jenkins"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsTaskDefinitionDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).ecsconn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_ecs_task_definition" {
|
||||
continue
|
||||
}
|
||||
|
||||
out, err := conn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{
|
||||
TaskDefinition: aws.String(rs.Primary.ID),
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
if out.TaskDefinition != nil {
|
||||
return fmt.Errorf("ECS task definition still exists:\n%#v", *out.TaskDefinition)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckAWSEcsTaskDefinitionExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
_, ok := s.RootModule().Resources[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var testAccAWSEcsTaskDefinition = `
|
||||
resource "aws_ecs_task_definition" "jenkins" {
|
||||
family = "jenkins"
|
||||
container_definitions = <<TASK_DEFINITION
|
||||
[
|
||||
{
|
||||
"cpu": 10,
|
||||
"command": ["sleep", "10"],
|
||||
"entryPoint": ["/"],
|
||||
"environment": [
|
||||
{"name": "VARNAME", "value": "VARVAL"}
|
||||
],
|
||||
"essential": true,
|
||||
"image": "jenkins",
|
||||
"links": ["mongodb"],
|
||||
"memory": 128,
|
||||
"name": "jenkins",
|
||||
"portMappings": [
|
||||
{
|
||||
"containerPort": 80,
|
||||
"hostPort": 8080
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cpu": 10,
|
||||
"command": ["sleep", "10"],
|
||||
"entryPoint": ["/"],
|
||||
"essential": true,
|
||||
"image": "mongodb",
|
||||
"memory": 128,
|
||||
"name": "mongodb",
|
||||
"portMappings": [
|
||||
{
|
||||
"containerPort": 28017,
|
||||
"hostPort": 28017
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
TASK_DEFINITION
|
||||
|
||||
volume {
|
||||
name = "jenkins-home"
|
||||
host_path = "/ecs/jenkins-home"
|
||||
}
|
||||
}
|
||||
`
|
|
@ -6,9 +6,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSEIP_normal(t *testing.T) {
|
||||
func TestAccAWSEIP_basic(t *testing.T) {
|
||||
var conf ec2.Address
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -52,8 +52,7 @@ func resourceAwsElasticacheCluster() *schema.Resource {
|
|||
},
|
||||
"port": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Default: 11211,
|
||||
Optional: true,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"engine_version": &schema.Schema{
|
||||
|
@ -123,7 +122,7 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
|
|||
numNodes := int64(d.Get("num_cache_nodes").(int)) // 2
|
||||
engine := d.Get("engine").(string) // memcached
|
||||
engineVersion := d.Get("engine_version").(string) // 1.4.14
|
||||
port := int64(d.Get("port").(int)) // 11211
|
||||
port := int64(d.Get("port").(int)) // e.g) 11211
|
||||
subnetGroupName := d.Get("subnet_group_name").(string)
|
||||
securityNameSet := d.Get("security_group_names").(*schema.Set)
|
||||
securityIdSet := d.Get("security_group_ids").(*schema.Set)
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -32,6 +32,7 @@ func TestAccAWSElasticacheCluster_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
|
||||
var csg elasticache.CacheSubnetGroup
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -40,7 +41,7 @@ func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccAWSElasticacheClusterInVPCConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar"),
|
||||
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar", &csg),
|
||||
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar"),
|
||||
),
|
||||
},
|
||||
|
@ -120,6 +121,7 @@ resource "aws_elasticache_cluster" "bar" {
|
|||
engine = "memcached"
|
||||
node_type = "cache.m1.small"
|
||||
num_cache_nodes = 1
|
||||
port = 11211
|
||||
parameter_group_name = "default.memcached1.4"
|
||||
security_group_names = ["${aws_elasticache_security_group.bar.name}"]
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSElasticacheSecurityGroup(t *testing.T) {
|
||||
func TestAccAWSElasticacheSecurityGroup_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -17,13 +17,13 @@ func resourceAwsElasticacheSubnetGroup() *schema.Resource {
|
|||
return &schema.Resource{
|
||||
Create: resourceAwsElasticacheSubnetGroupCreate,
|
||||
Read: resourceAwsElasticacheSubnetGroupRead,
|
||||
Update: resourceAwsElasticacheSubnetGroupUpdate,
|
||||
Delete: resourceAwsElasticacheSubnetGroupDelete,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"description": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -34,7 +34,6 @@ func resourceAwsElasticacheSubnetGroup() *schema.Resource {
|
|||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
|
@ -110,6 +109,29 @@ func resourceAwsElasticacheSubnetGroupRead(d *schema.ResourceData, meta interfac
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsElasticacheSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).elasticacheconn
|
||||
if d.HasChange("subnet_ids") || d.HasChange("description") {
|
||||
var subnets []*string
|
||||
if v := d.Get("subnet_ids"); v != nil {
|
||||
for _, v := range v.(*schema.Set).List() {
|
||||
subnets = append(subnets, aws.String(v.(string)))
|
||||
}
|
||||
}
|
||||
log.Printf("[DEBUG] Updating ElastiCache Subnet Group")
|
||||
|
||||
_, err := conn.ModifyCacheSubnetGroup(&elasticache.ModifyCacheSubnetGroupInput{
|
||||
CacheSubnetGroupName: aws.String(d.Get("name").(string)),
|
||||
CacheSubnetGroupDescription: aws.String(d.Get("description").(string)),
|
||||
SubnetIDs: subnets,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return resourceAwsElasticacheSubnetGroupRead(d, meta)
|
||||
}
|
||||
func resourceAwsElasticacheSubnetGroupDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).elasticacheconn
|
||||
|
||||
|
|
|
@ -4,22 +4,56 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elasticache"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSElasticacheSubnetGroup(t *testing.T) {
|
||||
func TestAccAWSElasticacheSubnetGroup_basic(t *testing.T) {
|
||||
var csg elasticache.CacheSubnetGroup
|
||||
config := fmt.Sprintf(testAccAWSElasticacheSubnetGroupConfig, genRandInt())
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSElasticacheSubnetGroupDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSElasticacheSubnetGroupConfig,
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar"),
|
||||
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar", &csg),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSElasticacheSubnetGroup_update(t *testing.T) {
|
||||
var csg elasticache.CacheSubnetGroup
|
||||
rn := "aws_elasticache_subnet_group.bar"
|
||||
ri := genRandInt()
|
||||
preConfig := fmt.Sprintf(testAccAWSElasticacheSubnetGroupUpdateConfigPre, ri)
|
||||
postConfig := fmt.Sprintf(testAccAWSElasticacheSubnetGroupUpdateConfigPost, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSElasticacheSubnetGroupDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSElasticacheSubnetGroupExists(rn, &csg),
|
||||
testAccCheckAWSElastiCacheSubnetGroupAttrs(&csg, rn, 1),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSElasticacheSubnetGroupExists(rn, &csg),
|
||||
testAccCheckAWSElastiCacheSubnetGroupAttrs(&csg, rn, 2),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -46,7 +80,7 @@ func testAccCheckAWSElasticacheSubnetGroupDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckAWSElasticacheSubnetGroupExists(n string) resource.TestCheckFunc {
|
||||
func testAccCheckAWSElasticacheSubnetGroupExists(n string, csg *elasticache.CacheSubnetGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -58,17 +92,47 @@ func testAccCheckAWSElasticacheSubnetGroupExists(n string) resource.TestCheckFun
|
|||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).elasticacheconn
|
||||
_, err := conn.DescribeCacheSubnetGroups(&elasticache.DescribeCacheSubnetGroupsInput{
|
||||
resp, err := conn.DescribeCacheSubnetGroups(&elasticache.DescribeCacheSubnetGroupsInput{
|
||||
CacheSubnetGroupName: aws.String(rs.Primary.ID),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("CacheSubnetGroup error: %v", err)
|
||||
}
|
||||
|
||||
for _, c := range resp.CacheSubnetGroups {
|
||||
if rs.Primary.ID == *c.CacheSubnetGroupName {
|
||||
*csg = *c
|
||||
}
|
||||
}
|
||||
|
||||
if csg == nil {
|
||||
return fmt.Errorf("cache subnet group not found")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var testAccAWSElasticacheSubnetGroupConfig = fmt.Sprintf(`
|
||||
func testAccCheckAWSElastiCacheSubnetGroupAttrs(csg *elasticache.CacheSubnetGroup, n string, count int) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if len(csg.Subnets) != count {
|
||||
return fmt.Errorf("Bad cache subnet count, expected: %d, got: %d", count, len(csg.Subnets))
|
||||
}
|
||||
|
||||
if rs.Primary.Attributes["description"] != *csg.CacheSubnetGroupDescription {
|
||||
return fmt.Errorf("Bad cache subnet description, expected: %s, got: %s", rs.Primary.Attributes["description"], *csg.CacheSubnetGroupDescription)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var testAccAWSElasticacheSubnetGroupConfig = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "192.168.0.0/16"
|
||||
tags {
|
||||
|
@ -90,4 +154,63 @@ resource "aws_elasticache_subnet_group" "bar" {
|
|||
description = "tf-test-cache-subnet-group-descr"
|
||||
subnet_ids = ["${aws_subnet.foo.id}"]
|
||||
}
|
||||
`, genRandInt())
|
||||
`
|
||||
var testAccAWSElasticacheSubnetGroupUpdateConfigPre = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
tags {
|
||||
Name = "tf-elc-sub-test"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "foo" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
cidr_block = "10.0.1.0/24"
|
||||
availability_zone = "us-west-2a"
|
||||
tags {
|
||||
Name = "tf-test"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_elasticache_subnet_group" "bar" {
|
||||
name = "tf-test-cache-subnet-%03d"
|
||||
description = "tf-test-cache-subnet-group-descr"
|
||||
subnet_ids = ["${aws_subnet.foo.id}"]
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAWSElasticacheSubnetGroupUpdateConfigPost = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
tags {
|
||||
Name = "tf-elc-sub-test"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "foo" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
cidr_block = "10.0.1.0/24"
|
||||
availability_zone = "us-west-2a"
|
||||
tags {
|
||||
Name = "tf-test"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "bar" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
cidr_block = "10.0.2.0/24"
|
||||
availability_zone = "us-west-2a"
|
||||
tags {
|
||||
Name = "tf-test-foo-update"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_elasticache_subnet_group" "bar" {
|
||||
name = "tf-test-cache-subnet-%03d"
|
||||
description = "tf-test-cache-subnet-group-descr-edited"
|
||||
subnet_ids = [
|
||||
"${aws_subnet.foo.id}",
|
||||
"${aws_subnet.bar.id}",
|
||||
]
|
||||
}
|
||||
`
|
||||
|
|
|
@ -4,10 +4,11 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -541,9 +542,11 @@ func resourceAwsElbListenerHash(v interface{}) int {
|
|||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["instance_port"].(int)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["instance_protocol"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-",
|
||||
strings.ToLower(m["instance_protocol"].(string))))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["lb_port"].(int)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["lb_protocol"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%s-",
|
||||
strings.ToLower(m["lb_protocol"].(string))))
|
||||
|
||||
if v, ok := m["ssl_certificate_id"]; ok {
|
||||
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -362,6 +362,39 @@ func TestAccAWSELB_SecurityGroups(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// Unit test for listeners hash
|
||||
func TestResourceAwsElbListenerHash(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
Left map[string]interface{}
|
||||
Right map[string]interface{}
|
||||
Match bool
|
||||
}{
|
||||
"protocols are case insensitive": {
|
||||
map[string]interface{}{
|
||||
"instance_port": 80,
|
||||
"instance_protocol": "TCP",
|
||||
"lb_port": 80,
|
||||
"lb_protocol": "TCP",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"instance_port": 80,
|
||||
"instance_protocol": "Tcp",
|
||||
"lb_port": 80,
|
||||
"lb_protocol": "tcP",
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for tn, tc := range cases {
|
||||
leftHash := resourceAwsElbListenerHash(tc.Left)
|
||||
rightHash := resourceAwsElbListenerHash(tc.Right)
|
||||
if (leftHash == rightHash) != tc.Match {
|
||||
t.Fatalf("%s: expected match: %t, but did not get it", tn, tc.Match)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckAWSELBDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).elbconn
|
||||
|
||||
|
@ -513,7 +546,8 @@ resource "aws_elb" "bar" {
|
|||
instance_port = 8000
|
||||
instance_protocol = "http"
|
||||
lb_port = 80
|
||||
lb_protocol = "http"
|
||||
// Protocol should be case insensitive
|
||||
lb_protocol = "HttP"
|
||||
}
|
||||
|
||||
tags {
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSAccessKey_normal(t *testing.T) {
|
||||
func TestAccAWSAccessKey_basic(t *testing.T) {
|
||||
var conf iam.AccessKeyMetadata
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSIAMGroupPolicy(t *testing.T) {
|
||||
func TestAccAWSIAMGroupPolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSIAMGroup_normal(t *testing.T) {
|
||||
func TestAccAWSIAMGroup_basic(t *testing.T) {
|
||||
var conf iam.GetGroupOutput
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAWSIAMInstanceProfile(t *testing.T) {
|
||||
func TestAccAWSIAMInstanceProfile_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -59,7 +59,7 @@ func resourceAwsIamPolicyCreate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
response, err := iamconn.CreatePolicy(request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating IAM policy %s: %#v", name, err)
|
||||
return fmt.Errorf("Error creating IAM policy %s: %s", name, err)
|
||||
}
|
||||
|
||||
return readIamPolicy(d, response.Policy)
|
||||
|
@ -78,7 +78,7 @@ func resourceAwsIamPolicyRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Error reading IAM policy %s: %#v", d.Id(), err)
|
||||
return fmt.Errorf("Error reading IAM policy %s: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
return readIamPolicy(d, response.Policy)
|
||||
|
@ -101,7 +101,7 @@ func resourceAwsIamPolicyUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
if _, err := iamconn.CreatePolicyVersion(request); err != nil {
|
||||
return fmt.Errorf("Error updating IAM policy %s: %#v", d.Id(), err)
|
||||
return fmt.Errorf("Error updating IAM policy %s: %s", d.Id(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func iamPolicyDeleteVersion(arn, versionID string, iamconn *iam.IAM) error {
|
|||
|
||||
_, err := iamconn.DeletePolicyVersion(request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting version %s from IAM policy %s: %#v", versionID, arn, err)
|
||||
return fmt.Errorf("Error deleting version %s from IAM policy %s: %s", versionID, arn, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ func iamPolicyListVersions(arn string, iamconn *iam.IAM) ([]*iam.PolicyVersion,
|
|||
|
||||
response, err := iamconn.ListPolicyVersions(request)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error listing versions for IAM policy %s: %#v", arn, err)
|
||||
return nil, fmt.Errorf("Error listing versions for IAM policy %s: %s", arn, err)
|
||||
}
|
||||
return response.Versions, nil
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSIAMRolePolicy(t *testing.T) {
|
||||
func TestAccAWSIAMRolePolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSRole_normal(t *testing.T) {
|
||||
func TestAccAWSRole_basic(t *testing.T) {
|
||||
var conf iam.GetRoleOutput
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -3,9 +3,9 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSIAMUserPolicy(t *testing.T) {
|
||||
func TestAccAWSIAMUserPolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/iam"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSUser_normal(t *testing.T) {
|
||||
func TestAccAWSUser_basic(t *testing.T) {
|
||||
var conf iam.GetUserOutput
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -85,6 +85,7 @@ func resourceAwsInstance() *schema.Resource {
|
|||
"source_dest_check": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
|
||||
"user_data": &schema.Schema{
|
||||
|
|
|
@ -5,15 +5,15 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSInstance_normal(t *testing.T) {
|
||||
func TestAccAWSInstance_basic(t *testing.T) {
|
||||
var v ec2.Instance
|
||||
var vol *ec2.Volume
|
||||
|
||||
|
@ -653,7 +653,6 @@ resource "aws_instance" "foo" {
|
|||
ami = "ami-4fccb37f"
|
||||
instance_type = "m1.small"
|
||||
subnet_id = "${aws_subnet.foo.id}"
|
||||
source_dest_check = true
|
||||
}
|
||||
`
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
)
|
||||
|
||||
func resourceAwsKeyPair() *schema.Resource {
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSKeyPair_normal(t *testing.T) {
|
||||
func TestAccAWSKeyPair_basic(t *testing.T) {
|
||||
var conf ec2.KeyPairInfo
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/kinesis"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/kinesis"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/kinesis"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/kinesis"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -7,13 +7,33 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSLaunchConfiguration_basic(t *testing.T) {
|
||||
var conf autoscaling.LaunchConfiguration
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSLaunchConfigurationDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSLaunchConfigurationNoNameConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSLaunchConfigurationExists("aws_launch_configuration.bar", &conf),
|
||||
testAccCheckAWSLaunchConfigurationGeneratedNamePrefix(
|
||||
"aws_launch_configuration.bar", "terraform-"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSLaunchConfiguration_withBlockDevices(t *testing.T) {
|
||||
var conf autoscaling.LaunchConfiguration
|
||||
|
||||
|
@ -61,26 +81,6 @@ func TestAccAWSLaunchConfiguration_withSpotPrice(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSLaunchConfiguration_withGeneratedName(t *testing.T) {
|
||||
var conf autoscaling.LaunchConfiguration
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSLaunchConfigurationDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSLaunchConfigurationNoNameConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSLaunchConfigurationExists("aws_launch_configuration.bar", &conf),
|
||||
testAccCheckAWSLaunchConfigurationGeneratedNamePrefix(
|
||||
"aws_launch_configuration.bar", "terraform-"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckAWSLaunchConfigurationGeneratedNamePrefix(
|
||||
resource, prefix string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAwsLBCookieStickinessPolicy(t *testing.T) {
|
||||
func TestAccAwsLBCookieStickinessPolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSMainRouteTableAssociation(t *testing.T) {
|
||||
func TestAccAWSMainRouteTableAssociation_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -78,9 +78,17 @@ func resourceAwsNetworkInterfaceCreate(d *schema.ResourceData, meta interface{})
|
|||
conn := meta.(*AWSClient).ec2conn
|
||||
|
||||
request := &ec2.CreateNetworkInterfaceInput{
|
||||
Groups: expandStringList(d.Get("security_groups").(*schema.Set).List()),
|
||||
SubnetID: aws.String(d.Get("subnet_id").(string)),
|
||||
PrivateIPAddresses: expandPrivateIPAddesses(d.Get("private_ips").(*schema.Set).List()),
|
||||
}
|
||||
|
||||
security_groups := d.Get("security_groups").(*schema.Set).List()
|
||||
if len(security_groups) != 0 {
|
||||
request.Groups = expandStringList(security_groups)
|
||||
}
|
||||
|
||||
private_ips := d.Get("private_ips").(*schema.Set).List()
|
||||
if len(private_ips) != 0 {
|
||||
request.PrivateIPAddresses = expandPrivateIPAddesses(private_ips)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating network interface")
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/elb"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/elb"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSProxyProtocolPolicy(t *testing.T) {
|
||||
func TestAccAWSProxyProtocolPolicy_basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func resourceAwsRoute53Record() *schema.Resource {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func TestCleanRecordName(t *testing.T) {
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func resourceAwsRoute53Zone() *schema.Resource {
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func resourceAwsRoute53ZoneAssociation() *schema.Resource {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func TestAccRoute53ZoneAssociation_basic(t *testing.T) {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
)
|
||||
|
||||
func TestCleanPrefix(t *testing.T) {
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -361,7 +361,10 @@ func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error
|
|||
func resourceAwsRouteTableHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["cidr_block"].(string)))
|
||||
|
||||
if v, ok := m["cidr_block"]; ok {
|
||||
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
|
||||
}
|
||||
|
||||
if v, ok := m["gateway_id"]; ok {
|
||||
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSRouteTableAssociation(t *testing.T) {
|
||||
func TestAccAWSRouteTableAssociation_basic(t *testing.T) {
|
||||
var v, v2 ec2.RouteTable
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -4,14 +4,14 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSRouteTable_normal(t *testing.T) {
|
||||
func TestAccAWSRouteTable_basic(t *testing.T) {
|
||||
var v ec2.RouteTable
|
||||
|
||||
testCheck := func(*terraform.State) error {
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
func resourceAwsS3Bucket() *schema.Resource {
|
||||
|
@ -433,6 +433,13 @@ func websiteEndpoint(s3conn *s3.S3, d *schema.ResourceData) (string, error) {
|
|||
|
||||
func WebsiteEndpointUrl(bucket string, region string) string {
|
||||
region = normalizeRegion(region)
|
||||
|
||||
// Frankfurt(and probably future) regions uses different syntax for website endpoints
|
||||
// http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html
|
||||
if region == "eu-central-1" {
|
||||
return fmt.Sprintf("%s.s3-website.%s.amazonaws.com", bucket, region)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.s3-website-%s.amazonaws.com", bucket, region)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/s3"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
func TestAccAWSS3Bucket_basic(t *testing.T) {
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAWSSecurityGroup_normal(t *testing.T) {
|
||||
func TestAccAWSSecurityGroup_basic(t *testing.T) {
|
||||
var group ec2.SecurityGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
@ -6,18 +6,17 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/sns"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/sns"
|
||||
)
|
||||
|
||||
// Mutable attributes
|
||||
var SNSAttributeMap = map[string]string{
|
||||
"display_name" : "DisplayName",
|
||||
"policy" : "Policy",
|
||||
"display_name": "DisplayName",
|
||||
"policy": "Policy",
|
||||
"delivery_policy": "DeliveryPolicy",
|
||||
}
|
||||
|
||||
|
||||
func resourceAwsSnsTopic() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsSnsTopicCreate,
|
||||
|
@ -117,8 +116,8 @@ func resourceAwsSnsTopicRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if attributeOutput.Attributes != nil && len(*attributeOutput.Attributes) > 0 {
|
||||
attrmap := *attributeOutput.Attributes
|
||||
if attributeOutput.Attributes != nil && len(attributeOutput.Attributes) > 0 {
|
||||
attrmap := attributeOutput.Attributes
|
||||
resource := *resourceAwsSnsTopic()
|
||||
// iKey = internal struct key, oKey = AWS Attribute Map key
|
||||
for iKey, oKey := range SNSAttributeMap {
|
||||
|
|
|
@ -6,11 +6,10 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/service/sns"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/sns"
|
||||
)
|
||||
|
||||
|
||||
func resourceAwsSnsTopicSubscription() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAwsSnsTopicSubscriptionCreate,
|
||||
|
@ -56,7 +55,7 @@ func resourceAwsSnsTopicSubscription() *schema.Resource {
|
|||
func resourceAwsSnsTopicSubscriptionCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
snsconn := meta.(*AWSClient).snsconn
|
||||
|
||||
if(d.Get("protocol") == "email") {
|
||||
if d.Get("protocol") == "email" {
|
||||
return fmt.Errorf("Email endpoints are not supported!")
|
||||
}
|
||||
|
||||
|
@ -132,8 +131,8 @@ func resourceAwsSnsTopicSubscriptionRead(d *schema.ResourceData, meta interface{
|
|||
return err
|
||||
}
|
||||
|
||||
if attributeOutput.Attributes != nil && len(*attributeOutput.Attributes) > 0 {
|
||||
attrHash := *attributeOutput.Attributes
|
||||
if attributeOutput.Attributes != nil && len(attributeOutput.Attributes) > 0 {
|
||||
attrHash := attributeOutput.Attributes
|
||||
log.Printf("[DEBUG] raw message delivery: %s", *attrHash["RawMessageDelivery"])
|
||||
if *attrHash["RawMessageDelivery"] == "true" {
|
||||
d.Set("raw_message_delivery", true)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue