Skip to content

Commit

Permalink
Merge branch 'master' into f-aws-rds-tags
Browse files Browse the repository at this point in the history
* master: (172 commits)
  core: [tests] fix order dependent test
  Fix hashcode for ASG test
  provider/aws: Fix issue with tainted ASG groups failing to re-create
  Don't error when reading s3 bucket with no tags
  Avoid panics when DBName is not set
  Add floating IP association in aceptance tests
  Use env var OS_POOL_NAME as default for pool attribute
  providers/heroku: Add heroku-postgres to example
  docs: resource addressing
  providers/heroku: Document environment variables
  providers/heroku: Add region to example
  Bugfix on floating IP assignment
  Update CHANGELOG.md
  update CHANGELOG
  website: note on docker
  core: formalize resource addressing
  core: fill out context tests for targeted ops
  core: docs for targeted operations
  core: targeted operations
  user_data support
  ...
  • Loading branch information
catsby committed Apr 1, 2015
2 parents 38c3864 + 816c4b4 commit d16492a
Show file tree
Hide file tree
Showing 127 changed files with 10,506 additions and 196 deletions.
41 changes: 36 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,26 @@ BACKWARDS INCOMPATIBILITIES:
FEATURES:

* **New provider: `dme` (DNSMadeEasy)** [GH-855]
* **New provider: `docker` (Docker)** - Manage container lifecycle
using the standard Docker API. [GH-855]
* **New provider: `openstack` (OpenStack)** - Interact with the many resources
provided by OpenStack. [GH-924]
* **New command: `taint`** - Manually mark a resource as tainted, causing
a destroy and recreate on the next plan/apply.
* **New resource: `aws_vpn_gateway`** [GH-1137]
* **New resource: `aws_elastic_network_interfaces`** [GH-1149]
* **Self-variables** can be used to reference the current resource's
attributes within a provisioner. Ex. `${self.private_ip_address}` [GH-1033]
* **Continous state** saving during `terraform apply`. The state file is
continously updated as apply is running, meaning that the state is
* **Continuous state** saving during `terraform apply`. The state file is
continuously updated as apply is running, meaning that the state is
less likely to become corrupt in a catastrophic case: terraform panic
or system killing Terraform.
* **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
`awslabs` refactored the library, and will move back to the officially
supported version in the next release.

IMPROVEMENTS:

Expand All @@ -34,7 +43,7 @@ IMPROVEMENTS:
* **New config function: `split`** - Split a value based on a delimiter.
This is useful for faking lists as parameters to modules.
* **New resource: `digitalocean_ssh_key`** [GH-1074]
* **New resource: `aws_elastic_network_interfaces`** [GH-1149]
* config: Expand `~` with homedir in `file()` paths [GH-1338]
* core: The serial of the state is only updated if there is an actual
change. This will lower the amount of state changing on things
like refresh.
Expand All @@ -43,6 +52,11 @@ IMPROVEMENTS:
* command/remote-config: After enabling remote state, a `pull` is
automatically done initially.
* providers/google: Add `size` option to disk blocks for instances. [GH-1284]
* providers/aws: Improve support for tagging resources.
* providers/aws: Add a short syntax for Route 53 Record names, e.g.
`www` instead of `www.example.com`.
* providers/aws: Improve dependency violation error handling, when deleting
Internet Gateways or Auto Scaling groups [GH-1325].

BUG FIXES:

Expand All @@ -55,15 +69,31 @@ BUG FIXES:
a computed attribute was used as part of a set parameter. [GH-1073]
* core: Fix edge case where state containing both "resource" and
"resource.0" would ignore the latter completely. [GH-1086]
* core: Modules with a source of a relative file path moving up
directories work properly, i.e. "../a" [GH-1232]
* providers/aws: manually deleted VPC removes it from the state
* providers/aws: `source_dest_check` regression fixed (now works). [GH-1020]
* providers/aws: Longer wait times for DB instances.
* providers/aws: Longer wait times for route53 records (30 mins). [GH-1164]
* providers/aws: Fix support for TXT records in Route 53. [GH-1213]
* providers/aws: Fix support for wildcard records in Route 53. [GH-1222]
* providers/aws: Fix issue with ignoring the 'self' attribute of a
Security Group rule. [GH-1223]
* providers/aws: Fix issue with `sql_mode` in RDS parameter group always
causing an update. [GH-1225]
* providers/aws: Fix dependency violation with subnets and security groups
[GH-1252]
* providers/aws: Fix issue with refreshing `db_subnet_groups` causing an error
instead of updating state [GH-1254]
* providers/aws: Prevent empty string to be used as default
`health_check_type` [GH-1052]
* providers/aws: Add tags on AWS IG creation, not just on update [GH-1176]
* providers/digitalocean: Waits until droplet is ready to be destroyed [GH-1057]
* providers/digitalocean: More lenient about 404's while waiting [GH-1062]
* providers/digitalocean: FQDN for domain records in CNAME, MX, NS, etc.
Also fixes invalid updates in plans. [GH-863]
* providers/google: Network data in state was not being stored. [GH-1095]
* providers/heroku: Fix panic when config vars block was empty. [GH-1211]

PLUGIN CHANGES:

Expand All @@ -90,7 +120,7 @@ IMPROVEMENTS:
* provider/aws: The `aws_db_instance` resource no longer requires both
`final_snapshot_identifier` and `skip_final_snapshot`; the presence or
absence of the former now implies the latter. [GH-874]
* provider/aws: Avoid unecessary update of `aws_subnet` when
* provider/aws: Avoid unnecessary update of `aws_subnet` when
`map_public_ip_on_launch` is not specified in config. [GH-898]
* provider/aws: Add `apply_method` to `aws_db_parameter_group` [GH-897]
* provider/aws: Add `storage_type` to `aws_db_instance` [GH-896]
Expand Down Expand Up @@ -123,7 +153,7 @@ BUG FIXES:
* command/apply: Fix regression where user variables weren't asked [GH-736]
* helper/hashcode: Update `hash.String()` to always return a positive index.
Fixes issue where specific strings would convert to a negative index
and be ommited when creating Route53 records. [GH-967]
and be omitted when creating Route53 records. [GH-967]
* provider/aws: Automatically suffix the Route53 zone name on record names. [GH-312]
* provider/aws: Instance should ignore root EBS devices. [GH-877]
* provider/aws: Fix `aws_db_instance` to not recreate each time. [GH-874]
Expand Down Expand Up @@ -529,3 +559,4 @@ BUG FIXES:

* Initial release


4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ If you have never worked with Go before, you will have to complete the
following steps in order to be able to compile and test Terraform (or
use the Vagrantfile in this repo to stand up a dev VM).

1. Install Go. Make sure the Go version is at least Go 1.2. Terraform will not work with anything less than
Go 1.2. On a Mac, you can `brew install go` to install Go 1.2.
1. Install Go. Make sure the Go version is at least Go 1.4. Terraform will not work with anything less than
Go 1.4. On a Mac, you can `brew install go` to install Go 1.4.

2. Set and export the `GOPATH` environment variable and update your `PATH`.
For example, you can add to your `.bash_profile`.
Expand Down
12 changes: 12 additions & 0 deletions builtin/bins/provider-docker/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"github.com/hashicorp/terraform/builtin/providers/docker"
"github.com/hashicorp/terraform/plugin"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: docker.Provider,
})
}
1 change: 1 addition & 0 deletions builtin/bins/provider-docker/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main
12 changes: 12 additions & 0 deletions builtin/bins/provider-openstack/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"github.com/hashicorp/terraform/builtin/providers/openstack"
"github.com/hashicorp/terraform/plugin"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: openstack.Provider,
})
}
7 changes: 6 additions & 1 deletion builtin/providers/aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{})
return err
}

return nil
return resource.Retry(5*time.Minute, func() error {
if g, _ = getAwsAutoscalingGroup(d, meta); g != nil {
return fmt.Errorf("Auto Scaling Group still exists")
}
return nil
})
}

func getAwsAutoscalingGroup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) {
testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group),
testAccCheckAWSAutoScalingGroupAttributes(&group),
resource.TestCheckResourceAttr(
"aws_autoscaling_group.bar", "availability_zones.1807834199", "us-west-2a"),
"aws_autoscaling_group.bar", "availability_zones.2487133097", "us-west-2a"),
resource.TestCheckResourceAttr(
"aws_autoscaling_group.bar", "name", "foobar3-terraform-test"),
resource.TestCheckResourceAttr(
Expand Down
6 changes: 5 additions & 1 deletion builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

d.Set("name", *v.DBName)
if v.DBName != nil {
d.Set("name", *v.DBName)
} else {
d.Set("name", "")
}
d.Set("username", *v.MasterUsername)
d.Set("engine", *v.Engine)
d.Set("engine_version", *v.EngineVersion)
Expand Down
6 changes: 6 additions & 0 deletions builtin/providers/aws/resource_aws_instance_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ func resourceAwsInstanceMigrateState(
}

func migrateStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {
if is.Empty() {
log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
return is, nil
}

log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)

// Delete old count
delete(is.Attributes, "block_device.#")

Expand Down
24 changes: 24 additions & 0 deletions builtin/providers/aws/resource_aws_instance_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func TestAWSInstanceMigrateState(t *testing.T) {

for tn, tc := range cases {
is := &terraform.InstanceState{
ID: "i-abc123",
Attributes: tc.Attributes,
}
is, err := resourceAwsInstanceMigrateState(
Expand All @@ -133,3 +134,26 @@ func TestAWSInstanceMigrateState(t *testing.T) {
}
}
}

func TestAWSInstanceMigrateState_empty(t *testing.T) {
var is *terraform.InstanceState
var meta interface{}

// should handle nil
is, err := resourceAwsInstanceMigrateState(0, is, meta)

if err != nil {
t.Fatalf("err: %#v", err)
}
if is != nil {
t.Fatalf("expected nil instancestate, got: %#v", is)
}

// should handle non-nil but empty
is = &terraform.InstanceState{}
is, err = resourceAwsInstanceMigrateState(0, is, meta)

if err != nil {
t.Fatalf("err: %#v", err)
}
}
6 changes: 2 additions & 4 deletions builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
return err
}

resp, err := s3conn.GetBucketTagging(&s3.GetBucketTaggingRequest{
Bucket: aws.String(d.Id()),
})
tagSet, err := getTagSetS3(s3conn, d.Id())
if err != nil {
return err
}

if err := d.Set("tags", tagsToMapS3(resp.TagSet)); err != nil {
if err := d.Set("tags", tagsToMapS3(tagSet)); err != nil {
return err
}

Expand Down
30 changes: 15 additions & 15 deletions builtin/providers/aws/resource_aws_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func TestAccAWSSecurityGroup_normal(t *testing.T) {
resource.TestCheckResourceAttr(
"aws_security_group.web", "description", "Used in the terraform acceptance tests"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.protocol", "tcp"),
"aws_security_group.web", "ingress.3629188364.protocol", "tcp"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.from_port", "80"),
"aws_security_group.web", "ingress.3629188364.from_port", "80"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.to_port", "8000"),
"aws_security_group.web", "ingress.3629188364.to_port", "8000"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.cidr_blocks.#", "1"),
"aws_security_group.web", "ingress.3629188364.cidr_blocks.#", "1"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.cidr_blocks.0", "10.0.0.0/8"),
"aws_security_group.web", "ingress.3629188364.cidr_blocks.0", "10.0.0.0/8"),
),
},
},
Expand Down Expand Up @@ -116,25 +116,25 @@ func TestAccAWSSecurityGroup_vpc(t *testing.T) {
resource.TestCheckResourceAttr(
"aws_security_group.web", "description", "Used in the terraform acceptance tests"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.protocol", "tcp"),
"aws_security_group.web", "ingress.3629188364.protocol", "tcp"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.from_port", "80"),
"aws_security_group.web", "ingress.3629188364.from_port", "80"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.to_port", "8000"),
"aws_security_group.web", "ingress.3629188364.to_port", "8000"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.cidr_blocks.#", "1"),
"aws_security_group.web", "ingress.3629188364.cidr_blocks.#", "1"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "ingress.332851786.cidr_blocks.0", "10.0.0.0/8"),
"aws_security_group.web", "ingress.3629188364.cidr_blocks.0", "10.0.0.0/8"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "egress.332851786.protocol", "tcp"),
"aws_security_group.web", "egress.3629188364.protocol", "tcp"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "egress.332851786.from_port", "80"),
"aws_security_group.web", "egress.3629188364.from_port", "80"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "egress.332851786.to_port", "8000"),
"aws_security_group.web", "egress.3629188364.to_port", "8000"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "egress.332851786.cidr_blocks.#", "1"),
"aws_security_group.web", "egress.3629188364.cidr_blocks.#", "1"),
resource.TestCheckResourceAttr(
"aws_security_group.web", "egress.332851786.cidr_blocks.0", "10.0.0.0/8"),
"aws_security_group.web", "egress.3629188364.cidr_blocks.0", "10.0.0.0/8"),
testCheck,
),
},
Expand Down
19 changes: 19 additions & 0 deletions builtin/providers/aws/s3_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,22 @@ func tagsToMapS3(ts []s3.Tag) map[string]string {

return result
}

// return a slice of s3 tags associated with the given s3 bucket. Essentially
// s3.GetBucketTagging, except returns an empty slice instead of an error when
// there are no tags.
func getTagSetS3(s3conn *s3.S3, bucket string) ([]s3.Tag, error) {
request := &s3.GetBucketTaggingRequest{
Bucket: aws.String(bucket),
}

response, err := s3conn.GetBucketTagging(request)
if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "NoSuchTagSet" {
// There is no tag set associated with the bucket.
return []s3.Tag{}, nil
} else if err != nil {
return nil, err
}

return response.TagSet, nil
}
33 changes: 33 additions & 0 deletions builtin/providers/docker/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package docker

import (
"path/filepath"

dc "github.com/fsouza/go-dockerclient"
)

// Config is the structure that stores the configuration to talk to a
// Docker API compatible host.
type Config struct {
Host string
CertPath string
}

// NewClient() returns a new Docker client.
func (c *Config) NewClient() (*dc.Client, error) {
// If there is no cert information, then just return the direct client
if c.CertPath == "" {
return dc.NewClient(c.Host)
}

// If there is cert information, load it and use it.
ca := filepath.Join(c.CertPath, "ca.pem")
cert := filepath.Join(c.CertPath, "cert.pem")
key := filepath.Join(c.CertPath, "key.pem")
return dc.NewTLSClient(c.Host, cert, key, ca)
}

// Data ia structure for holding data that we fetch from Docker.
type Data struct {
DockerImages map[string]*dc.APIImages
}
Loading

0 comments on commit d16492a

Please sign in to comment.