Skip to content

Commit

Permalink
Merge branch 'master' into f-aws-elastic-beanstalk
Browse files Browse the repository at this point in the history
* master: (30 commits)
  Update CHANGELOG.md
  Prompt for input variables before context validate
  Change the docs as the token can be explicitly set
  Add test attempting to reproduce #2598
  Update CHANGELOG.md
  provider/openstack: Revert Security Group Rule Fix
  Update rds_cluster.html.markdown
  Reflect new comment format in stringer.go
  Always deploy from stable website branch
  Fix spelling mistake in aws iam saml title
  Fix spelling mistake in aws saml example
  provider/openstack: extend documentation of Neutron::FloatingIP
  Add coalesce func
  config: remove debug line
  config: new HCL API
  Update CHANGELOG.md
  providers/google: add pubsub auth endpoint #3803
  provider/openstack: Make Security Groups Computed
  add closing quote
  Update CHANGELOG.md
  ...
  • Loading branch information
catsby committed Nov 10, 2015
2 parents c257708 + bd35d21 commit 781c22b
Show file tree
Hide file tree
Showing 35 changed files with 644 additions and 287 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ FEATURES:
* **New resource: `google_compute_target_https_proxy`** [GH-3728]
* **New resource: `google_compute_global_forwarding_rule`** [GH-3702]
* **New resource: `openstack_networking_port_v2`** [GH-3731]
* New interpolation function: `coalesce` [GH-3814]

IMPROVEMENTS:

Expand All @@ -27,6 +28,8 @@ IMPROVEMENTS:
* provider/aws: Add notification topic ARN for ElastiCache clusters [GH-3674]
* provider/aws: Add `kinesis_endpoint` for configuring Kinesis [GH-3255]
* provider/aws: Add a computed ARN for S3 Buckets [GH-3685]
* provider/aws: Add S3 support for Lambda Function resource [GH-3794]
* provider/aws: Add snapshot window and retention limits for ElastiCache (Redis) [GH-3707]
* provider/aws: Add configuration to enable copying RDS tags to final snapshot [GH-3529]
* provider/aws: RDS Cluster additions (`backup_retention_period`, `preferred_backup_window`, `preferred_maintenance_window`) [GH-3757]
* provider/openstack: Use IPv4 as the defeault IP version for subnets [GH-3091]
Expand All @@ -41,6 +44,7 @@ BUG FIXES:

* `terraform remote config`: update `--help` output [GH-3632]
* core: modules on Git branches now update properly [GH-1568]
* core: Fix issue preventing input prompts for unset variables during plan [GH-3843]
* provider/google: Timeout when deleting large instance_group_manager [GH-3591]
* provider/aws: Fix issue with order of Termincation Policies in AutoScaling Groups.
This will introduce plans on upgrade to this version, in order to correct the ordering [GH-2890]
Expand All @@ -58,6 +62,7 @@ BUG FIXES:
* provider/openstack: Fix boot from volume [GH-3206]
* provider/openstack: Fix crashing when image is no longer accessible [GH-2189]
* provider/openstack: Better handling of network resource state changes [GH-3712]
* provider/openstack: Fix crashing when no security group is specified [GH-3801]

## 0.6.6 (October 23, 2015)

Expand Down
38 changes: 38 additions & 0 deletions builtin/providers/aws/resource_aws_elasticache_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ func resourceAwsElasticacheCluster() *schema.Resource {
},
},

"snapshot_window": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},

"snapshot_retention_limit": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
value := v.(int)
if value > 35 {
es = append(es, fmt.Errorf(
"snapshot retention limit cannot be more than 35 days"))
}
return
},
},

"tags": tagsSchema(),

// apply_immediately is used to determine when the update modifications
Expand Down Expand Up @@ -187,6 +205,14 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
req.CacheParameterGroupName = aws.String(v.(string))
}

if v, ok := d.GetOk("snapshot_retention_limit"); ok {
req.SnapshotRetentionLimit = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("snapshot_window"); ok {
req.SnapshotWindow = aws.String(v.(string))
}

if v, ok := d.GetOk("maintenance_window"); ok {
req.PreferredMaintenanceWindow = aws.String(v.(string))
}
Expand Down Expand Up @@ -267,6 +293,8 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
d.Set("security_group_ids", c.SecurityGroups)
d.Set("parameter_group_name", c.CacheParameterGroup)
d.Set("maintenance_window", c.PreferredMaintenanceWindow)
d.Set("snapshot_window", c.SnapshotWindow)
d.Set("snapshot_retention_limit", c.SnapshotRetentionLimit)
if c.NotificationConfiguration != nil {
if *c.NotificationConfiguration.TopicStatus == "active" {
d.Set("notification_topic_arn", c.NotificationConfiguration.TopicArn)
Expand Down Expand Up @@ -350,6 +378,16 @@ func resourceAwsElasticacheClusterUpdate(d *schema.ResourceData, meta interface{
requestUpdate = true
}

if d.HasChange("snapshot_window") {
req.SnapshotWindow = aws.String(d.Get("snapshot_window").(string))
requestUpdate = true
}

if d.HasChange("snapshot_retention_limit") {
req.SnapshotRetentionLimit = aws.Int64(int64(d.Get("snapshot_retention_limit").(int)))
requestUpdate = true
}

if d.HasChange("num_cache_nodes") {
req.NumCacheNodes = aws.Int64(int64(d.Get("num_cache_nodes").(int)))
requestUpdate = true
Expand Down
108 changes: 108 additions & 0 deletions builtin/providers/aws/resource_aws_elasticache_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,45 @@ func TestAccAWSElasticacheCluster_basic(t *testing.T) {
})
}

func TestAccAWSElasticacheCluster_snapshotsWithUpdates(t *testing.T) {
var ec elasticache.CacheCluster

ri := genRandInt()
preConfig := fmt.Sprintf(testAccAWSElasticacheClusterConfig_snapshots, ri, ri, ri)
postConfig := fmt.Sprintf(testAccAWSElasticacheClusterConfig_snapshotsUpdated, ri, ri, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "snapshot_window", "05:00-09:00"),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "snapshot_retention_limit", "3"),
),
},

resource.TestStep{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "snapshot_window", "07:00-09:00"),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "snapshot_retention_limit", "7"),
),
},
},
})
}

func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
var csg elasticache.CacheSubnetGroup
var ec elasticache.CacheCluster
Expand Down Expand Up @@ -152,6 +191,75 @@ resource "aws_elasticache_cluster" "bar" {
}
`, genRandInt(), genRandInt(), genRandInt())

var testAccAWSElasticacheClusterConfig_snapshots = `
provider "aws" {
region = "us-east-1"
}
resource "aws_security_group" "bar" {
name = "tf-test-security-group-%03d"
description = "tf-test-security-group-descr"
ingress {
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_elasticache_security_group" "bar" {
name = "tf-test-security-group-%03d"
description = "tf-test-security-group-descr"
security_group_names = ["${aws_security_group.bar.name}"]
}
resource "aws_elasticache_cluster" "bar" {
cluster_id = "tf-test-%03d"
engine = "redis"
node_type = "cache.m1.small"
num_cache_nodes = 1
port = 6379
parameter_group_name = "default.redis2.8"
security_group_names = ["${aws_elasticache_security_group.bar.name}"]
snapshot_window = "05:00-09:00"
snapshot_retention_limit = 3
}
`

var testAccAWSElasticacheClusterConfig_snapshotsUpdated = `
provider "aws" {
region = "us-east-1"
}
resource "aws_security_group" "bar" {
name = "tf-test-security-group-%03d"
description = "tf-test-security-group-descr"
ingress {
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_elasticache_security_group" "bar" {
name = "tf-test-security-group-%03d"
description = "tf-test-security-group-descr"
security_group_names = ["${aws_security_group.bar.name}"]
}
resource "aws_elasticache_cluster" "bar" {
cluster_id = "tf-test-%03d"
engine = "redis"
node_type = "cache.m1.small"
num_cache_nodes = 1
port = 6379
parameter_group_name = "default.redis2.8"
security_group_names = ["${aws_elasticache_security_group.bar.name}"]
snapshot_window = "07:00-09:00"
snapshot_retention_limit = 7
apply_immediately = true
}
`

var testAccAWSElasticacheClusterInVPCConfig = fmt.Sprintf(`
resource "aws_vpc" "foo" {
cidr_block = "192.168.0.0/16"
Expand Down
64 changes: 48 additions & 16 deletions builtin/providers/aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/mitchellh/go-homedir"

"errors"

"github.com/hashicorp/terraform/helper/schema"
)

Expand All @@ -25,13 +27,28 @@ func resourceAwsLambdaFunction() *schema.Resource {

Schema: map[string]*schema.Schema{
"filename": &schema.Schema{
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"s3_bucket", "s3_key", "s3_object_version"},
},
"s3_bucket": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"filename"},
},
"s3_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"filename"},
},
"s3_object_version": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"filename"},
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true, // TODO make this editable
},
"function_name": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -93,22 +110,36 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e

log.Printf("[DEBUG] Creating Lambda Function %s with role %s", functionName, iamRole)

filename, err := homedir.Expand(d.Get("filename").(string))
if err != nil {
return err
}
zipfile, err := ioutil.ReadFile(filename)
if err != nil {
return err
var functionCode *lambda.FunctionCode
if v, ok := d.GetOk("filename"); ok {
filename, err := homedir.Expand(v.(string))
if err != nil {
return err
}
zipfile, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
d.Set("source_code_hash", sha256.Sum256(zipfile))
functionCode = &lambda.FunctionCode{
ZipFile: zipfile,
}
} else {
s3Bucket, bucketOk := d.GetOk("s3_bucket")
s3Key, keyOk := d.GetOk("s3_key")
s3ObjectVersion, versionOk := d.GetOk("s3_object_version")
if !bucketOk || !keyOk || !versionOk {
return errors.New("s3_bucket, s3_key and s3_object_version must all be set while using S3 code source")
}
functionCode = &lambda.FunctionCode{
S3Bucket: aws.String(s3Bucket.(string)),
S3Key: aws.String(s3Key.(string)),
S3ObjectVersion: aws.String(s3ObjectVersion.(string)),
}
}
d.Set("source_code_hash", sha256.Sum256(zipfile))

log.Printf("[DEBUG] ")

params := &lambda.CreateFunctionInput{
Code: &lambda.FunctionCode{
ZipFile: zipfile,
},
Code: functionCode,
Description: aws.String(d.Get("description").(string)),
FunctionName: aws.String(functionName),
Handler: aws.String(d.Get("handler").(string)),
Expand All @@ -118,6 +149,7 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e
Timeout: aws.Int64(int64(d.Get("timeout").(int))),
}

var err error
for i := 0; i < 5; i++ {
_, err = conn.CreateFunction(params)
if awsErr, ok := err.(awserr.Error); ok {
Expand Down
9 changes: 5 additions & 4 deletions builtin/providers/google/service_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func canonicalizeServiceScope(scope string) string {
"datastore": "https://www.googleapis.com/auth/datastore",
"logging-write": "https://www.googleapis.com/auth/logging.write",
"monitoring": "https://www.googleapis.com/auth/monitoring",
"pubsub": "https://www.googleapis.com/auth/pubsub",
"sql": "https://www.googleapis.com/auth/sqlservice",
"sql-admin": "https://www.googleapis.com/auth/sqlservice.admin",
"storage-full": "https://www.googleapis.com/auth/devstorage.full_control",
Expand All @@ -22,9 +23,9 @@ func canonicalizeServiceScope(scope string) string {
"userinfo-email": "https://www.googleapis.com/auth/userinfo.email",
}

if matchedUrl, ok := scopeMap[scope]; ok {
return matchedUrl
} else {
return scope
if matchedURL, ok := scopeMap[scope]; ok {
return matchedURL
}

return scope
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func resourceComputeInstanceV2() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
ForceNew: false,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
Expand Down
2 changes: 1 addition & 1 deletion command/counthookaction_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions command/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ func (c *PlanCommand) Run(args []string) int {
c.Ui.Error(err.Error())
return 1
}
if !validateContext(ctx, c.Ui) {
return 1
}

if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}

if !validateContext(ctx, c.Ui) {
return 1
}

if refresh {
c.Ui.Output("Refreshing Terraform state prior to plan...\n")
state, err := ctx.Refresh()
Expand Down
Loading

0 comments on commit 781c22b

Please sign in to comment.