Skip to content

Commit

Permalink
Merge #4272: custom JSON for Opsworks layers
Browse files Browse the repository at this point in the history
  • Loading branch information
apparentlymart committed Apr 16, 2016
2 parents 51b1c0e + 41a8220 commit 72f121a
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions builtin/providers/aws/opsworks_layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func (lt *opsworksLayerType) SchemaResource() *schema.Resource {
Set: schema.HashString,
},

"custom_json": &schema.Schema{
Type: schema.TypeString,
StateFunc: normalizeJson,
Optional: true,
},

"auto_healing": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -288,6 +294,14 @@ func (lt *opsworksLayerType) Read(d *schema.ResourceData, client *opsworks.OpsWo
d.Set("short_name", layer.Shortname)
}

if v := layer.CustomJson; v == nil {
if err := d.Set("custom_json", ""); err != nil {
return err
}
} else if err := d.Set("custom_json", normalizeJson(*v)); err != nil {
return err
}

lt.SetAttributeMap(d, layer.Attributes)
lt.SetLifecycleEventConfiguration(d, layer.LifecycleEventConfiguration)
lt.SetCustomRecipes(d, layer.CustomRecipes)
Expand Down Expand Up @@ -342,6 +356,10 @@ func (lt *opsworksLayerType) Create(d *schema.ResourceData, client *opsworks.Ops
req.Shortname = aws.String(lt.TypeName)
}

if customJson, ok := d.GetOk("custom_json"); ok {
req.CustomJson = aws.String(customJson.(string))
}

log.Printf("[DEBUG] Creating OpsWorks layer: %s", d.Id())

resp, err := client.CreateLayer(req)
Expand Down Expand Up @@ -393,6 +411,10 @@ func (lt *opsworksLayerType) Update(d *schema.ResourceData, client *opsworks.Ops
req.Shortname = aws.String(lt.TypeName)
}

if customJson, ok := d.GetOk("custom_json"); ok {
req.CustomJson = aws.String(customJson.(string))
}

log.Printf("[DEBUG] Updating OpsWorks layer: %s", d.Id())

if d.HasChange("elastic_load_balancer") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func TestAccAWSOpsworksCustomLayer(t *testing.T) {
resource.TestCheckResourceAttr(
"aws_opsworks_custom_layer.tf-acc", "ebs_volume.1266957920.iops", "3000",
),
resource.TestCheckResourceAttr(
"aws_opsworks_custom_layer.tf-acc", "custom_json", `{"layer_key":"layer_value2"}`,
),
),
},
},
Expand Down Expand Up @@ -268,6 +271,7 @@ resource "aws_opsworks_custom_layer" "tf-acc" {
raid_level = 1
iops = 3000
}
custom_json = "{\"layer_key\": \"layer_value2\"}"
}
%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following arguments are supported:
* `username` - (Optiona) The username to use for Ganglia. Defaults to "opsworks".
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following arguments are supported:
* `system_packages` - (Optional) Names of a set of system packages to install on the layer's instances.
* `use_ebs_optimized_instances` - (Optional) Whether to use EBS-optimized instances.
* `ebs_volume` - (Optional) `ebs_volume` blocks, as described below, will each create an EBS volume and connect it to the layer's instances.
* `custom_json` - (Optional) Custom JSON attributes to apply to the layer.

The following extra optional arguments, all lists of Chef recipe names, allow
custom Chef recipes to be applied to layer instances at the five different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The following arguments are supported:
* `use_opsworks_security_groups` - (Optional) Boolean value controlling whether the standard OpsWorks
security groups apply to created instances.
* `vpc_id` - (Optional) The id of the VPC that this stack belongs to.
* `custom_json` - (Optional) Custom JSON attributes to apply to the entire stack.

The `custom_cookbooks_source` block supports the following arguments:

Expand Down

0 comments on commit 72f121a

Please sign in to comment.