Merge #4272: custom JSON for Opsworks layers

This commit is contained in:
Martin Atkins 2016-04-16 08:48:36 -07:00
commit 72f121aec1
12 changed files with 36 additions and 0 deletions

View File

@ -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,
@ -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)
@ -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)
@ -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") {

View File

@ -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"}`,
),
),
},
},
@ -268,6 +271,7 @@ resource "aws_opsworks_custom_layer" "tf-acc" {
raid_level = 1
iops = 3000
}
custom_json = "{\"layer_key\": \"layer_value2\"}"
}
%s

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: