Skip to content

Commit d70cdde

Browse files
committed
merging in upstream, because rebase was insane
2 parents 1d1de99 + 09bd4e7 commit d70cdde

63 files changed

Lines changed: 1943 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ website/node_modules
2020
*~
2121
.*.swp
2222
.idea
23+
*.test

CHANGELOG.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
## 0.6.7 (Unreleased)
1+
## 0.6.8 (Unreleased)
2+
3+
FEATURES:
4+
5+
* **New resource: `digitalocean_floating_ip`** [GH-3748]
6+
7+
IMPROVEMENTS:
8+
9+
BUG FIXES:
10+
11+
* provider/aws: Fixed a bug which could result in a panic when reading EC2 metadata [GH-4024]
12+
* provisioner/chef: Fix issue with path separators breaking the Chef provisioner on Windows [GH-4041]
13+
* providers/aws: Fix issue recreating security group rule if it has been destroyed [GH-4050]
14+
15+
## 0.6.7 (November 23, 2015)
216

317
FEATURES:
418

519
* **New provider: `tls`** - A utility provider for generating TLS keys/self-signed certificates for development and testing [GH-2778]
620
* **New provider: `dyn`** - Manage DNS records on Dyn
721
* **New resource: `aws_cloudformation_stack`** [GH-2636]
8-
* **New resource: `aws_cloudtrail`** [GH-3094]
22+
* **New resource: `aws_cloudtrail`** [GH-3094], [GH-4010]
923
* **New resource: `aws_route`** [GH-3548]
1024
* **New resource: `aws_codecommit_repository`** [GH-3274]
1125
* **New resource: `aws_kinesis_firehose_delivery_stream`** [GH-3833]
@@ -63,17 +77,24 @@ BUG FIXES:
6377
* `terraform remote config`: update `--help` output [GH-3632]
6478
* core: modules on Git branches now update properly [GH-1568]
6579
* core: Fix issue preventing input prompts for unset variables during plan [GH-3843]
80+
* core: Fix issue preventing input prompts for unset variables during refresh [GH-4017]
6681
* core: Orphan resources can now be targets [GH-3912]
82+
* helper/schema: skip StateFunc when value is nil [GH-4002]
6783
* provider/google: Timeout when deleting large instance_group_manager [GH-3591]
6884
* provider/aws: Fix issue with order of Termincation Policies in AutoScaling Groups.
6985
This will introduce plans on upgrade to this version, in order to correct the ordering [GH-2890]
7086
* provider/aws: Allow cluster name, not only ARN for `aws_ecs_service` [GH-3668]
87+
* provider/aws: Fix a bug where a non-lower-cased `maintenance_window` can cause unnecessary planned changes [GH-4020]
7188
* provider/aws: Only set `weight` on an `aws_route53_record` if it has been set in configuration [GH-3900]
7289
* provider/aws: ignore association not exist on route table destroy [GH-3615]
7390
* provider/aws: Fix policy encoding issue with SNS Topics [GH-3700]
7491
* provider/aws: Correctly export ARN in `aws_iam_saml_provider` [GH-3827]
92+
* provider/aws: Fix issue deleting users who are attached to a group [GH-4005]
7593
* provider/aws: Fix crash in Route53 Record if Zone not found [GH-3945]
76-
* providers/aws: Fix typo in error checking for IAM Policy Attachments #3970
94+
* providers/aws: Retry deleting IAM Server Cert on dependency violation [GH-3898]
95+
* providers/aws: Update Spot Instance request to provide connection information [GH-3940]
96+
* providers/aws: Fix typo in error checking for IAM Policy Attachments [GH-3970]
97+
* provider/aws: Fix issue with LB Cookie Stickiness and empty expiration period [GH-3908]
7798
* provider/aws: Tolerate ElastiCache clusters being deleted outside Terraform [GH-3767]
7899
* provider/aws: Downcase Route 53 record names in statefile to match API output [GH-3574]
79100
* provider/aws: Fix issue that could occur if no ECS Cluster was found for a give name [GH-3829]
@@ -84,6 +105,7 @@ BUG FIXES:
84105
* provider/aws: Fix issue with updating the `aws_ecs_task_definition` where `aws_ecs_service` didn't wait for a new computed ARN [GH-3924]
85106
* provider/aws: Prevent crashing when deleting `aws_ecs_service` that is already gone [GH-3914]
86107
* provider/aws: Allow spaces in `aws_db_subnet_group.name` (undocumented in the API) [GH-3955]
108+
* provider/aws: Make VPC ID required on subnets [GH-4021]
87109
* provider/azure: various bugfixes [GH-3695]
88110
* provider/digitalocean: fix issue preventing SSH fingerprints from working [GH-3633]
89111
* provider/digitalocean: Fixing the DigitalOcean Droplet 404 potential on refresh of state [GH-3768]

Vagrantfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
VAGRANTFILE_API_VERSION = "2"
66

77
$script = <<SCRIPT
8+
GOVERSION="1.5.1"
89
SRCROOT="/opt/go"
910
SRCPATH="/opt/gopath"
1011
@@ -18,8 +19,8 @@ sudo apt-get install -y build-essential curl git-core libpcre3-dev mercurial pkg
1819
1920
# Install Go
2021
cd /tmp
21-
wget -q https://storage.googleapis.com/golang/go1.4.2.linux-${ARCH}.tar.gz
22-
tar -xf go1.4.2.linux-${ARCH}.tar.gz
22+
wget --quiet https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz
23+
tar -xvf go${GOVERSION}.linux-${ARCH}.tar.gz
2324
sudo mv go $SRCROOT
2425
sudo chmod 775 $SRCROOT
2526
sudo chown vagrant:vagrant $SRCROOT

builtin/providers/aws/provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212

1313
"github.com/aws/aws-sdk-go/aws/credentials"
1414
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
15+
"github.com/aws/aws-sdk-go/aws/ec2metadata"
16+
"github.com/aws/aws-sdk-go/aws/session"
1517
)
1618

1719
// Provider returns a terraform.ResourceProvider.
@@ -42,7 +44,7 @@ func Provider() terraform.ResourceProvider {
4244
conn, err := net.DialTimeout("tcp", "169.254.169.254:80", 100*time.Millisecond)
4345
if err == nil {
4446
conn.Close()
45-
providers = append(providers, &ec2rolecreds.EC2RoleProvider{})
47+
providers = append(providers, &ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())})
4648
}
4749

4850
credVal, credErr = credentials.NewChainCredentials(providers).Get()

builtin/providers/aws/resource_aws_ami_copy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ resource "aws_instance" "test" {
171171
// one snapshot in our created AMI.
172172
// This is an Amazon Linux HVM AMI. A public HVM AMI is required
173173
// because paravirtual images cannot be copied between accounts.
174-
ami = "ami-8fff43e4"
174+
ami = "ami-5449393e"
175175
instance_type = "t2.micro"
176176
tags {
177177
Name = "terraform-acc-ami-copy-victim"

builtin/providers/aws/resource_aws_autoscaling_notification_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ resource "aws_autoscaling_notification" "example" {
240240
`
241241

242242
const testAccASGNotificationConfig_update = `
243-
resource "aws_sns_topic" "user_updates" {
243+
resource "aws_sns_topic" "topic_example" {
244244
name = "user-updates-topic"
245245
}
246246
@@ -286,7 +286,7 @@ resource "aws_autoscaling_notification" "example" {
286286
"autoscaling:EC2_INSTANCE_TERMINATE",
287287
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR"
288288
]
289-
topic_arn = "${aws_sns_topic.user_updates.arn}"
289+
topic_arn = "${aws_sns_topic.topic_example.arn}"
290290
}`
291291

292292
const testAccASGNotificationConfig_pagination = `

builtin/providers/aws/resource_aws_cloudtrail.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ func resourceAwsCloudTrail() *schema.Resource {
2222
Required: true,
2323
ForceNew: true,
2424
},
25+
"enable_logging": &schema.Schema{
26+
Type: schema.TypeBool,
27+
Optional: true,
28+
Default: true,
29+
},
2530
"s3_bucket_name": &schema.Schema{
2631
Type: schema.TypeString,
2732
Required: true,
@@ -84,6 +89,14 @@ func resourceAwsCloudTrailCreate(d *schema.ResourceData, meta interface{}) error
8489

8590
d.SetId(*t.Name)
8691

92+
// AWS CloudTrail sets newly-created trails to false.
93+
if v, ok := d.GetOk("enable_logging"); ok && v.(bool) {
94+
err := cloudTrailSetLogging(conn, v.(bool), d.Id())
95+
if err != nil {
96+
return err
97+
}
98+
}
99+
87100
return resourceAwsCloudTrailRead(d, meta)
88101
}
89102

@@ -115,6 +128,12 @@ func resourceAwsCloudTrailRead(d *schema.ResourceData, meta interface{}) error {
115128
d.Set("include_global_service_events", trail.IncludeGlobalServiceEvents)
116129
d.Set("sns_topic_name", trail.SnsTopicName)
117130

131+
logstatus, err := cloudTrailGetLoggingStatus(conn, trail.Name)
132+
if err != nil {
133+
return err
134+
}
135+
d.Set("enable_logging", logstatus)
136+
118137
return nil
119138
}
120139

@@ -149,6 +168,15 @@ func resourceAwsCloudTrailUpdate(d *schema.ResourceData, meta interface{}) error
149168
if err != nil {
150169
return err
151170
}
171+
172+
if d.HasChange("enable_logging") {
173+
log.Printf("[DEBUG] Updating logging on CloudTrail: %s", input)
174+
err := cloudTrailSetLogging(conn, d.Get("enable_logging").(bool), *input.Name)
175+
if err != nil {
176+
return err
177+
}
178+
}
179+
152180
log.Printf("[DEBUG] CloudTrail updated: %s", t)
153181

154182
return resourceAwsCloudTrailRead(d, meta)
@@ -165,3 +193,45 @@ func resourceAwsCloudTrailDelete(d *schema.ResourceData, meta interface{}) error
165193

166194
return err
167195
}
196+
197+
func cloudTrailGetLoggingStatus(conn *cloudtrail.CloudTrail, id *string) (bool, error) {
198+
GetTrailStatusOpts := &cloudtrail.GetTrailStatusInput{
199+
Name: id,
200+
}
201+
resp, err := conn.GetTrailStatus(GetTrailStatusOpts)
202+
if err != nil {
203+
return false, fmt.Errorf("Error retrieving logging status of CloudTrail (%s): %s", *id, err)
204+
}
205+
206+
return *resp.IsLogging, err
207+
}
208+
209+
func cloudTrailSetLogging(conn *cloudtrail.CloudTrail, enabled bool, id string) error {
210+
if enabled {
211+
log.Printf(
212+
"[DEBUG] Starting logging on CloudTrail (%s)",
213+
id)
214+
StartLoggingOpts := &cloudtrail.StartLoggingInput{
215+
Name: aws.String(id),
216+
}
217+
if _, err := conn.StartLogging(StartLoggingOpts); err != nil {
218+
return fmt.Errorf(
219+
"Error starting logging on CloudTrail (%s): %s",
220+
id, err)
221+
}
222+
} else {
223+
log.Printf(
224+
"[DEBUG] Stopping logging on CloudTrail (%s)",
225+
id)
226+
StopLoggingOpts := &cloudtrail.StopLoggingInput{
227+
Name: aws.String(id),
228+
}
229+
if _, err := conn.StopLogging(StopLoggingOpts); err != nil {
230+
return fmt.Errorf(
231+
"Error stopping logging on CloudTrail (%s): %s",
232+
id, err)
233+
}
234+
}
235+
236+
return nil
237+
}

builtin/providers/aws/resource_aws_cloudtrail_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,41 @@ func TestAccAWSCloudTrail_basic(t *testing.T) {
3939
})
4040
}
4141

42+
func TestAccAWSCloudTrail_enable_logging(t *testing.T) {
43+
var trail cloudtrail.Trail
44+
45+
resource.Test(t, resource.TestCase{
46+
PreCheck: func() { testAccPreCheck(t) },
47+
Providers: testAccProviders,
48+
CheckDestroy: testAccCheckAWSCloudTrailDestroy,
49+
Steps: []resource.TestStep{
50+
resource.TestStep{
51+
Config: testAccAWSCloudTrailConfig,
52+
Check: resource.ComposeTestCheckFunc(
53+
testAccCheckCloudTrailExists("aws_cloudtrail.foobar", &trail),
54+
// AWS will create the trail with logging turned off.
55+
// Test that "enable_logging" default works.
56+
testAccCheckCloudTrailLoggingEnabled("aws_cloudtrail.foobar", true, &trail),
57+
),
58+
},
59+
resource.TestStep{
60+
Config: testAccAWSCloudTrailConfigModified,
61+
Check: resource.ComposeTestCheckFunc(
62+
testAccCheckCloudTrailExists("aws_cloudtrail.foobar", &trail),
63+
testAccCheckCloudTrailLoggingEnabled("aws_cloudtrail.foobar", false, &trail),
64+
),
65+
},
66+
resource.TestStep{
67+
Config: testAccAWSCloudTrailConfig,
68+
Check: resource.ComposeTestCheckFunc(
69+
testAccCheckCloudTrailExists("aws_cloudtrail.foobar", &trail),
70+
testAccCheckCloudTrailLoggingEnabled("aws_cloudtrail.foobar", true, &trail),
71+
),
72+
},
73+
},
74+
})
75+
}
76+
4277
func testAccCheckCloudTrailExists(n string, trail *cloudtrail.Trail) resource.TestCheckFunc {
4378
return func(s *terraform.State) error {
4479
rs, ok := s.RootModule().Resources[n]
@@ -63,6 +98,30 @@ func testAccCheckCloudTrailExists(n string, trail *cloudtrail.Trail) resource.Te
6398
}
6499
}
65100

101+
func testAccCheckCloudTrailLoggingEnabled(n string, desired bool, trail *cloudtrail.Trail) resource.TestCheckFunc {
102+
return func(s *terraform.State) error {
103+
rs, ok := s.RootModule().Resources[n]
104+
if !ok {
105+
return fmt.Errorf("Not found: %s", n)
106+
}
107+
108+
conn := testAccProvider.Meta().(*AWSClient).cloudtrailconn
109+
params := cloudtrail.GetTrailStatusInput{
110+
Name: aws.String(rs.Primary.ID),
111+
}
112+
resp, err := conn.GetTrailStatus(&params)
113+
114+
if err != nil {
115+
return err
116+
}
117+
if *resp.IsLogging != desired {
118+
return fmt.Errorf("Expected logging status %t, given %t", desired, *resp.IsLogging)
119+
}
120+
121+
return nil
122+
}
123+
}
124+
66125
func testAccCheckAWSCloudTrailDestroy(s *terraform.State) error {
67126
conn := testAccProvider.Meta().(*AWSClient).cloudtrailconn
68127

@@ -134,6 +193,7 @@ resource "aws_cloudtrail" "foobar" {
134193
s3_bucket_name = "${aws_s3_bucket.foo.id}"
135194
s3_key_prefix = "/prefix"
136195
include_global_service_events = false
196+
enable_logging = false
137197
}
138198
139199
resource "aws_s3_bucket" "foo" {

builtin/providers/aws/resource_aws_elasticache_cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ func resourceAwsElasticacheCluster() *schema.Resource {
7171
Type: schema.TypeString,
7272
Optional: true,
7373
Computed: true,
74+
StateFunc: func(val interface{}) string {
75+
// Elasticache always changes the maintenance
76+
// to lowercase
77+
return strings.ToLower(val.(string))
78+
},
7479
},
7580
"subnet_group_name": &schema.Schema{
7681
Type: schema.TypeString,
@@ -141,6 +146,7 @@ func resourceAwsElasticacheCluster() *schema.Resource {
141146
"snapshot_window": &schema.Schema{
142147
Type: schema.TypeString,
143148
Optional: true,
149+
Computed: true,
144150
},
145151

146152
"snapshot_retention_limit": &schema.Schema{

builtin/providers/aws/resource_aws_elb.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"regexp"
88
"strings"
9+
"time"
910

1011
"github.com/aws/aws-sdk-go/aws"
1112
"github.com/aws/aws-sdk-go/aws/awserr"
@@ -256,8 +257,23 @@ func resourceAwsElbCreate(d *schema.ResourceData, meta interface{}) error {
256257
}
257258

258259
log.Printf("[DEBUG] ELB create configuration: %#v", elbOpts)
259-
if _, err := elbconn.CreateLoadBalancer(elbOpts); err != nil {
260-
return fmt.Errorf("Error creating ELB: %s", err)
260+
err = resource.Retry(1*time.Minute, func() error {
261+
_, err := elbconn.CreateLoadBalancer(elbOpts)
262+
263+
if err != nil {
264+
if awsErr, ok := err.(awserr.Error); ok {
265+
// Check for IAM SSL Cert error, eventual consistancy issue
266+
if awsErr.Code() == "CertificateNotFound" {
267+
return fmt.Errorf("[WARN] Error creating ELB Listener with SSL Cert, retrying: %s", err)
268+
}
269+
}
270+
return resource.RetryError{Err: err}
271+
}
272+
return nil
273+
})
274+
275+
if err != nil {
276+
return err
261277
}
262278

263279
// Assign the elb's unique identifier for use later
@@ -394,6 +410,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
394410
LoadBalancerPorts: ports,
395411
}
396412

413+
log.Printf("[DEBUG] ELB Delete Listeners opts: %s", deleteListenersOpts)
397414
_, err := elbconn.DeleteLoadBalancerListeners(deleteListenersOpts)
398415
if err != nil {
399416
return fmt.Errorf("Failure removing outdated ELB listeners: %s", err)
@@ -406,6 +423,7 @@ func resourceAwsElbUpdate(d *schema.ResourceData, meta interface{}) error {
406423
Listeners: add,
407424
}
408425

426+
log.Printf("[DEBUG] ELB Create Listeners opts: %s", createListenersOpts)
409427
_, err := elbconn.CreateLoadBalancerListeners(createListenersOpts)
410428
if err != nil {
411429
return fmt.Errorf("Failure adding new or updated ELB listeners: %s", err)

0 commit comments

Comments
 (0)