From bcd5904eeace2ab624231f34522089c979f4d068 Mon Sep 17 00:00:00 2001 From: Jeff Tang Date: Fri, 11 Dec 2015 18:35:22 -0500 Subject: [PATCH 001/665] Add support for Opsworks Instances New resource checklist - [x] Acceptance testing - [x] Documentation - [x] Well-formed code --- builtin/providers/aws/provider.go | 1 + .../aws/resource_aws_opsworks_instance.go | 998 ++++++++++++++++++ .../resource_aws_opsworks_instance_test.go | 211 ++++ .../aws/r/opsworks_instance.html.markdown | 133 +++ website/source/layouts/aws.erb | 4 + 5 files changed, 1347 insertions(+) create mode 100644 builtin/providers/aws/resource_aws_opsworks_instance.go create mode 100644 builtin/providers/aws/resource_aws_opsworks_instance_test.go create mode 100644 website/source/docs/providers/aws/r/opsworks_instance.html.markdown diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index e469c6756943..b401e2a12ca0 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -208,6 +208,7 @@ func Provider() terraform.ResourceProvider { "aws_opsworks_mysql_layer": resourceAwsOpsworksMysqlLayer(), "aws_opsworks_ganglia_layer": resourceAwsOpsworksGangliaLayer(), "aws_opsworks_custom_layer": resourceAwsOpsworksCustomLayer(), + "aws_opsworks_instance": resourceAwsOpsworksInstance(), "aws_placement_group": resourceAwsPlacementGroup(), "aws_proxy_protocol_policy": resourceAwsProxyProtocolPolicy(), "aws_rds_cluster": resourceAwsRDSCluster(), diff --git a/builtin/providers/aws/resource_aws_opsworks_instance.go b/builtin/providers/aws/resource_aws_opsworks_instance.go new file mode 100644 index 000000000000..dc4051f014bd --- /dev/null +++ b/builtin/providers/aws/resource_aws_opsworks_instance.go @@ -0,0 +1,998 @@ +package aws + +import ( + "bytes" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/helper/schema" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/opsworks" +) + +func resourceAwsOpsworksInstance() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsOpsworksInstanceCreate, + Read: resourceAwsOpsworksInstanceRead, + Update: resourceAwsOpsworksInstanceUpdate, + Delete: resourceAwsOpsworksInstanceDelete, + + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "agent_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "INHERIT", + }, + + "ami_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "architecture": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "x86_64", + ValidateFunc: validateArchitecture, + }, + + "auto_scaling_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateAutoScalingType, + }, + + "availability_zone": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "created_at": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "delete_ebs": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "delete_eip": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "ebs_optimized": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, + + "ec2_instance_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "ecs_cluster_arn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "elastic_ip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "hostname": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "infrastructure_class": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "install_updates_on_boot": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "instance_profile_arn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "instance_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "last_service_error_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "layer_ids": &schema.Schema{ + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "os": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "platform": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "private_dns": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "private_ip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "public_dns": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "public_ip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "registered_by": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "reported_agent_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "reported_os_family": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "reported_os_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "reported_os_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "root_device_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + ValidateFunc: validateRootDeviceType, + }, + + "root_device_volume_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "security_group_ids": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "ssh_host_dsa_key_fingerprint": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "ssh_host_rsa_key_fingerprint": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "ssh_key_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "stack_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "state": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateState, + }, + + "status": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + + "subnet_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "virtualization_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validateVirtualizationType, + }, + + "ebs_block_device": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Computed: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "delete_on_termination": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + }, + + "device_name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "iops": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "snapshot_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "volume_size": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "volume_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + }, + Set: func(v interface{}) int { + var buf bytes.Buffer + m := v.(map[string]interface{}) + buf.WriteString(fmt.Sprintf("%s-", m["device_name"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + return hashcode.String(buf.String()) + }, + }, + "ephemeral_block_device": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Computed: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "device_name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + + "virtual_name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + }, + }, + Set: func(v interface{}) int { + var buf bytes.Buffer + m := v.(map[string]interface{}) + buf.WriteString(fmt.Sprintf("%s-", m["device_name"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m["virtual_name"].(string))) + return hashcode.String(buf.String()) + }, + }, + + "root_block_device": &schema.Schema{ + // TODO: This is a set because we don't support singleton + // sub-resources today. We'll enforce that the set only ever has + // length zero or one below. When TF gains support for + // sub-resources this can be converted. + Type: schema.TypeSet, + Optional: true, + Computed: true, + ForceNew: true, + Elem: &schema.Resource{ + // "You can only modify the volume size, volume type, and Delete on + // Termination flag on the block device mapping entry for the root + // device volume." - bit.ly/ec2bdmap + Schema: map[string]*schema.Schema{ + "delete_on_termination": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + }, + + "iops": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "volume_size": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "volume_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + }, + Set: func(v interface{}) int { + // there can be only one root device; no need to hash anything + return 0 + }, + }, + }, + } +} + +func validateArchitecture(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "x86_64" && value != "i386" { + errors = append(errors, fmt.Errorf( + "%q must be one of \"x86_64\" or \"i386\"", k)) + } + return +} + +func validateAutoScalingType(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "load" && value != "timer" { + errors = append(errors, fmt.Errorf( + "%q must be one of \"load\" or \"timer\"", k)) + } + return +} + +func validateRootDeviceType(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "ebs" && value != "instance-store" { + errors = append(errors, fmt.Errorf( + "%q must be one of \"ebs\" or \"instance-store\"", k)) + } + return +} + +func validateState(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "running" && value != "stopped" { + errors = append(errors, fmt.Errorf( + "%q must be one of \"running\" or \"stopped\"", k)) + } + return +} + +func validateVirtualizationType(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "paravirtual" && value != "hvm" { + errors = append(errors, fmt.Errorf( + "%q must be one of \"paravirtual\" or \"hvm\"", k)) + } + return +} + +func resourceAwsOpsworksInstanceValidate(d *schema.ResourceData) error { + if d.HasChange("ami_id") { + if v, ok := d.GetOk("os"); ok { + if v.(string) != "Custom" { + return fmt.Errorf("OS must be \"Custom\" when using using a custom ami_id") + } + } + + if _, ok := d.GetOk("root_block_device"); ok { + return fmt.Errorf("Cannot specify root_block_device when using a custom ami_id.") + } + + if _, ok := d.GetOk("ebs_block_device"); ok { + return fmt.Errorf("Cannot specify ebs_block_device when using a custom ami_id.") + } + + if _, ok := d.GetOk("ephemeral_block_device"); ok { + return fmt.Errorf("Cannot specify ephemeral_block_device when using a custom ami_id.") + } + } + return nil +} + +func resourceAwsOpsworksInstanceRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + req := &opsworks.DescribeInstancesInput{ + InstanceIds: []*string{ + aws.String(d.Id()), + }, + } + + log.Printf("[DEBUG] Reading OpsWorks instance: %s", d.Id()) + + resp, err := client.DescribeInstances(req) + if err != nil { + if awserr, ok := err.(awserr.Error); ok { + if awserr.Code() == "ResourceNotFoundException" { + d.SetId("") + return nil + } + } + return err + } + + instance := resp.Instances[0] + instanceId := *instance.InstanceId + d.SetId(instanceId) + d.Set("agent_version", instance.AgentVersion) + d.Set("ami_id", instance.AmiId) + d.Set("architecture", instance.Architecture) + d.Set("auto_scaling_type", instance.AutoScalingType) + d.Set("availability_zone", instance.AvailabilityZone) + d.Set("created_at", instance.CreatedAt) + d.Set("ebs_optimized", instance.EbsOptimized) + d.Set("ec2_instance_id", instance.Ec2InstanceId) + d.Set("ecs_cluster_arn", instance.EcsClusterArn) + d.Set("elastic_ip", instance.ElasticIp) + d.Set("hostname", instance.Hostname) + d.Set("infrastructure_class", instance.InfrastructureClass) + d.Set("install_updates_on_boot", instance.InstallUpdatesOnBoot) + d.Set("id", instanceId) + d.Set("instance_profile_arn", instance.InstanceProfileArn) + d.Set("instance_type", instance.InstanceType) + d.Set("last_service_error_id", instance.LastServiceErrorId) + d.Set("layer_ids", instance.LayerIds) + d.Set("os", instance.Os) + d.Set("platform", instance.Platform) + d.Set("private_dns", instance.PrivateDns) + d.Set("private_ip", instance.PrivateIp) + d.Set("public_dns", instance.PublicDns) + d.Set("public_ip", instance.PublicIp) + d.Set("registered_by", instance.RegisteredBy) + d.Set("reported_agent_version", instance.ReportedAgentVersion) + d.Set("reported_os_family", instance.ReportedOs.Family) + d.Set("reported_os_name", instance.ReportedOs.Name) + d.Set("reported_os_version", instance.ReportedOs.Version) + d.Set("root_device_type", instance.RootDeviceType) + d.Set("root_device_volume_id", instance.RootDeviceVolumeId) + d.Set("ssh_host_dsa_key_fingerprint", instance.SshHostDsaKeyFingerprint) + d.Set("ssh_host_rsa_key_fingerprint", instance.SshHostRsaKeyFingerprint) + d.Set("ssh_key_name", instance.SshKeyName) + d.Set("stack_id", instance.StackId) + d.Set("status", instance.Status) + d.Set("subnet_id", instance.SubnetId) + d.Set("virtualization_type", instance.VirtualizationType) + + // Read BlockDeviceMapping + ibds, err := readOpsworksBlockDevices(d, instance, meta) + if err != nil { + return err + } + + if err := d.Set("ebs_block_device", ibds["ebs"]); err != nil { + return err + } + if err := d.Set("ephemeral_block_device", ibds["ephemeral"]); err != nil { + return err + } + if ibds["root"] != nil { + if err := d.Set("root_block_device", []interface{}{ibds["root"]}); err != nil { + return err + } + } else { + d.Set("root_block_device", []interface{}{}) + } + + // Read Security Groups + sgs := make([]string, 0, len(instance.SecurityGroupIds)) + for _, sg := range instance.SecurityGroupIds { + sgs = append(sgs, *sg) + } + if err := d.Set("security_group_ids", sgs); err != nil { + return err + } + + return nil +} + +func resourceAwsOpsworksInstanceCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + err := resourceAwsOpsworksInstanceValidate(d) + if err != nil { + return err + } + + req := &opsworks.CreateInstanceInput{ + AgentVersion: aws.String(d.Get("agent_version").(string)), + Architecture: aws.String(d.Get("architecture").(string)), + EbsOptimized: aws.Bool(d.Get("ebs_optimized").(bool)), + InstallUpdatesOnBoot: aws.Bool(d.Get("install_updates_on_boot").(bool)), + InstanceType: aws.String(d.Get("instance_type").(string)), + LayerIds: expandStringList(d.Get("layer_ids").([]interface{})), + StackId: aws.String(d.Get("stack_id").(string)), + } + + if v, ok := d.GetOk("ami_id"); ok { + req.AmiId = aws.String(v.(string)) + req.Os = aws.String("Custom") + } + + if v, ok := d.GetOk("auto_scaling_type"); ok { + req.AutoScalingType = aws.String(v.(string)) + } + + if v, ok := d.GetOk("availability_zone"); ok { + req.AvailabilityZone = aws.String(v.(string)) + } + + if v, ok := d.GetOk("hostname"); ok { + req.Hostname = aws.String(v.(string)) + } + + if v, ok := d.GetOk("os"); ok { + req.Os = aws.String(v.(string)) + } + + if v, ok := d.GetOk("root_device_type"); ok { + req.RootDeviceType = aws.String(v.(string)) + } + + if v, ok := d.GetOk("ssh_key_name"); ok { + req.SshKeyName = aws.String(v.(string)) + } + + if v, ok := d.GetOk("subnet_id"); ok { + req.SubnetId = aws.String(v.(string)) + } + + if v, ok := d.GetOk("virtualization_type"); ok { + req.VirtualizationType = aws.String(v.(string)) + } + + var blockDevices []*opsworks.BlockDeviceMapping + + if v, ok := d.GetOk("ebs_block_device"); ok { + vL := v.(*schema.Set).List() + for _, v := range vL { + bd := v.(map[string]interface{}) + ebs := &opsworks.EbsBlockDevice{ + DeleteOnTermination: aws.Bool(bd["delete_on_termination"].(bool)), + } + + if v, ok := bd["snapshot_id"].(string); ok && v != "" { + ebs.SnapshotId = aws.String(v) + } + + if v, ok := bd["volume_size"].(int); ok && v != 0 { + ebs.VolumeSize = aws.Int64(int64(v)) + } + + if v, ok := bd["volume_type"].(string); ok && v != "" { + ebs.VolumeType = aws.String(v) + } + + if v, ok := bd["iops"].(int); ok && v > 0 { + ebs.Iops = aws.Int64(int64(v)) + } + + blockDevices = append(blockDevices, &opsworks.BlockDeviceMapping{ + DeviceName: aws.String(bd["device_name"].(string)), + Ebs: ebs, + }) + } + } + + if v, ok := d.GetOk("ephemeral_block_device"); ok { + vL := v.(*schema.Set).List() + for _, v := range vL { + bd := v.(map[string]interface{}) + blockDevices = append(blockDevices, &opsworks.BlockDeviceMapping{ + DeviceName: aws.String(bd["device_name"].(string)), + VirtualName: aws.String(bd["virtual_name"].(string)), + }) + } + } + + if v, ok := d.GetOk("root_block_device"); ok { + vL := v.(*schema.Set).List() + if len(vL) > 1 { + return fmt.Errorf("Cannot specify more than one root_block_device.") + } + for _, v := range vL { + bd := v.(map[string]interface{}) + ebs := &opsworks.EbsBlockDevice{ + DeleteOnTermination: aws.Bool(bd["delete_on_termination"].(bool)), + } + + if v, ok := bd["volume_size"].(int); ok && v != 0 { + ebs.VolumeSize = aws.Int64(int64(v)) + } + + if v, ok := bd["volume_type"].(string); ok && v != "" { + ebs.VolumeType = aws.String(v) + } + + if v, ok := bd["iops"].(int); ok && v > 0 { + ebs.Iops = aws.Int64(int64(v)) + } + + blockDevices = append(blockDevices, &opsworks.BlockDeviceMapping{ + DeviceName: aws.String("ROOT_DEVICE"), + Ebs: ebs, + }) + } + } + + if len(blockDevices) > 0 { + req.BlockDeviceMappings = blockDevices + } + + log.Printf("[DEBUG] Creating OpsWorks instance") + + var resp *opsworks.CreateInstanceOutput + + resp, err = client.CreateInstance(req) + if err != nil { + return err + } + + instanceId := *resp.InstanceId + d.SetId(instanceId) + d.Set("id", instanceId) + + if v, ok := d.GetOk("state"); ok && v.(string) == "running" { + err := startOpsworksInstance(d, meta, false) + if err != nil { + return err + } + } + + return resourceAwsOpsworksInstanceRead(d, meta) +} + +func resourceAwsOpsworksInstanceUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + err := resourceAwsOpsworksInstanceValidate(d) + if err != nil { + return err + } + + req := &opsworks.UpdateInstanceInput{ + AgentVersion: aws.String(d.Get("agent_version").(string)), + Architecture: aws.String(d.Get("architecture").(string)), + InstanceId: aws.String(d.Get("id").(string)), + InstallUpdatesOnBoot: aws.Bool(d.Get("install_updates_on_boot").(bool)), + } + + if v, ok := d.GetOk("ami_id"); ok { + req.AmiId = aws.String(v.(string)) + req.Os = aws.String("Custom") + } + + if v, ok := d.GetOk("auto_scaling_type"); ok { + req.AutoScalingType = aws.String(v.(string)) + } + + if v, ok := d.GetOk("hostname"); ok { + req.Hostname = aws.String(v.(string)) + } + + if v, ok := d.GetOk("instance_type"); ok { + req.InstanceType = aws.String(v.(string)) + } + + if v, ok := d.GetOk("layer_ids"); ok { + req.LayerIds = expandStringList(v.([]interface{})) + + } + + if v, ok := d.GetOk("os"); ok { + req.Os = aws.String(v.(string)) + } + + if v, ok := d.GetOk("ssh_key_name"); ok { + req.SshKeyName = aws.String(v.(string)) + } + + log.Printf("[DEBUG] Updating OpsWorks instance: %s", d.Id()) + + _, err = client.UpdateInstance(req) + if err != nil { + return err + } + + var status string + + if v, ok := d.GetOk("status"); ok { + status = v.(string) + } else { + status = "stopped" + } + + if v, ok := d.GetOk("state"); ok { + state := v.(string) + if state == "running" { + if status == "stopped" || status == "stopping" || status == "shutting_down" { + err := startOpsworksInstance(d, meta, false) + if err != nil { + return err + } + } + } else { + if status != "stopped" && status != "stopping" && status != "shutting_down" { + err := stopOpsworksInstance(d, meta, false) + if err != nil { + return err + } + } + } + } + + return resourceAwsOpsworksInstanceRead(d, meta) +} + +func resourceAwsOpsworksInstanceDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + if v, ok := d.GetOk("status"); ok && v.(string) != "stopped" { + err := stopOpsworksInstance(d, meta, true) + if err != nil { + return err + } + } + + req := &opsworks.DeleteInstanceInput{ + InstanceId: aws.String(d.Id()), + DeleteElasticIp: aws.Bool(d.Get("delete_eip").(bool)), + DeleteVolumes: aws.Bool(d.Get("delete_ebs").(bool)), + } + + log.Printf("[DEBUG] Deleting OpsWorks instance: %s", d.Id()) + + _, err := client.DeleteInstance(req) + if err != nil { + return err + } + + d.SetId("") + return nil +} + +func startOpsworksInstance(d *schema.ResourceData, meta interface{}, wait bool) error { + client := meta.(*AWSClient).opsworksconn + + instanceId := d.Get("id").(string) + + req := &opsworks.StartInstanceInput{ + InstanceId: aws.String(instanceId), + } + + log.Printf("[DEBUG] Starting OpsWorks instance: %s", instanceId) + + _, err := client.StartInstance(req) + + if err != nil { + return err + } + + if wait { + log.Printf("[DEBUG] Waiting for instance (%s) to become running", instanceId) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"requested", "pending", "booting", "running_setup"}, + Target: []string{"online"}, + Refresh: OpsworksInstanceStateRefreshFunc(client, instanceId), + Timeout: 10 * time.Minute, + Delay: 10 * time.Second, + MinTimeout: 3 * time.Second, + } + _, err = stateConf.WaitForState() + if err != nil { + return fmt.Errorf("Error waiting for instance (%s) to become stopped: %s", + instanceId, err) + } + } + + return nil +} + +func stopOpsworksInstance(d *schema.ResourceData, meta interface{}, wait bool) error { + client := meta.(*AWSClient).opsworksconn + + instanceId := d.Get("id").(string) + + req := &opsworks.StopInstanceInput{ + InstanceId: aws.String(instanceId), + } + + log.Printf("[DEBUG] Stopping OpsWorks instance: %s", instanceId) + + _, err := client.StopInstance(req) + + if err != nil { + return err + } + + if wait { + log.Printf("[DEBUG] Waiting for instance (%s) to become stopped", instanceId) + + stateConf := &resource.StateChangeConf{ + Pending: []string{"stopping", "terminating", "shutting_down", "terminated"}, + Target: []string{"stopped"}, + Refresh: OpsworksInstanceStateRefreshFunc(client, instanceId), + Timeout: 10 * time.Minute, + Delay: 10 * time.Second, + MinTimeout: 3 * time.Second, + } + _, err = stateConf.WaitForState() + if err != nil { + return fmt.Errorf("Error waiting for instance (%s) to become stopped: %s", + instanceId, err) + } + } + + return nil +} + +func readOpsworksBlockDevices(d *schema.ResourceData, instance *opsworks.Instance, meta interface{}) ( + map[string]interface{}, error) { + + blockDevices := make(map[string]interface{}) + blockDevices["ebs"] = make([]map[string]interface{}, 0) + blockDevices["ephemeral"] = make([]map[string]interface{}, 0) + blockDevices["root"] = nil + + if len(instance.BlockDeviceMappings) == 0 { + return nil, nil + } + + for _, bdm := range instance.BlockDeviceMappings { + bd := make(map[string]interface{}) + if bdm.Ebs != nil && bdm.Ebs.DeleteOnTermination != nil { + bd["delete_on_termination"] = *bdm.Ebs.DeleteOnTermination + } + if bdm.Ebs != nil && bdm.Ebs.VolumeSize != nil { + bd["volume_size"] = *bdm.Ebs.VolumeSize + } + if bdm.Ebs != nil && bdm.Ebs.VolumeType != nil { + bd["volume_type"] = *bdm.Ebs.VolumeType + } + if bdm.Ebs != nil && bdm.Ebs.Iops != nil { + bd["iops"] = *bdm.Ebs.Iops + } + if bdm.DeviceName != nil && *bdm.DeviceName == "ROOT_DEVICE" { + blockDevices["root"] = bd + } else { + if bdm.DeviceName != nil { + bd["device_name"] = *bdm.DeviceName + } + if bdm.VirtualName != nil { + bd["virtual_name"] = *bdm.VirtualName + blockDevices["ephemeral"] = append(blockDevices["ephemeral"].([]map[string]interface{}), bd) + } else { + if bdm.Ebs != nil && bdm.Ebs.SnapshotId != nil { + bd["snapshot_id"] = *bdm.Ebs.SnapshotId + } + blockDevices["ebs"] = append(blockDevices["ebs"].([]map[string]interface{}), bd) + } + } + } + return blockDevices, nil +} + +func OpsworksInstanceStateRefreshFunc(conn *opsworks.OpsWorks, instanceID string) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + resp, err := conn.DescribeInstances(&opsworks.DescribeInstancesInput{ + InstanceIds: []*string{aws.String(instanceID)}, + }) + if err != nil { + if awserr, ok := err.(awserr.Error); ok && awserr.Code() == "ResourceNotFoundException" { + // Set this to nil as if we didn't find anything. + resp = nil + } else { + log.Printf("Error on OpsworksInstanceStateRefresh: %s", err) + return nil, "", err + } + } + + if resp == nil || len(resp.Instances) == 0 { + // Sometimes AWS just has consistency issues and doesn't see + // our instance yet. Return an empty state. + return nil, "", nil + } + + i := resp.Instances[0] + return i, *i.Status, nil + } +} diff --git a/builtin/providers/aws/resource_aws_opsworks_instance_test.go b/builtin/providers/aws/resource_aws_opsworks_instance_test.go new file mode 100644 index 000000000000..82d02b63e57b --- /dev/null +++ b/builtin/providers/aws/resource_aws_opsworks_instance_test.go @@ -0,0 +1,211 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/opsworks" + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +// These tests assume the existence of predefined Opsworks IAM roles named `aws-opsworks-ec2-role` +// and `aws-opsworks-service-role`. + +func TestAccAWSOpsworksInstance(t *testing.T) { + stackName := fmt.Sprintf("tf-%d", acctest.RandInt()) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsOpsworksInstanceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAwsOpsworksInstanceConfigCreate(stackName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "hostname", "tf-acc1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "instance_type", "t2.micro", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "state", "stopped", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "layer_ids.#", "1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "install_updates_on_boot", "true", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "architecture", "x86_64", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2014.09", // inherited from opsworks_stack_test + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "root_device_type", "ebs", // inherited from opsworks_stack_test + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "availability_zone", "us-west-2a", // inherited from opsworks_stack_test + ), + ), + }, + resource.TestStep{ + Config: testAccAwsOpsworksInstanceConfigUpdate(stackName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "hostname", "tf-acc1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "instance_type", "t2.small", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "layer_ids.#", "2", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2015.09", + ), + ), + }, + }, + }) +} + +func testAccCheckAwsOpsworksInstanceDestroy(s *terraform.State) error { + opsworksconn := testAccProvider.Meta().(*AWSClient).opsworksconn + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_opsworks_instance" { + continue + } + req := &opsworks.DescribeInstancesInput{ + InstanceIds: []*string{ + aws.String(rs.Primary.ID), + }, + } + + _, err := opsworksconn.DescribeInstances(req) + if err != nil { + if awserr, ok := err.(awserr.Error); ok { + if awserr.Code() == "ResourceNotFoundException" { + // not found, good to go + return nil + } + } + return err + } + } + + return fmt.Errorf("Fall through error on OpsWorks instance test") +} + +func testAccAwsOpsworksInstanceConfigCreate(name string) string { + return fmt.Sprintf(` +resource "aws_security_group" "tf-ops-acc-web" { + name = "%s-web" + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_security_group" "tf-ops-acc-php" { + name = "%s-php" + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_opsworks_static_web_layer" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + + custom_security_group_ids = [ + "${aws_security_group.tf-ops-acc-web.id}", + ] +} + +resource "aws_opsworks_php_app_layer" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + + custom_security_group_ids = [ + "${aws_security_group.tf-ops-acc-php.id}", + ] +} + +resource "aws_opsworks_instance" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + layer_ids = [ + "${aws_opsworks_static_web_layer.tf-acc.id}", + ] + instance_type = "t2.micro" + state = "stopped" + hostname = "tf-acc1" +} + +%s + +`, name, name, testAccAwsOpsworksStackConfigVpcCreate(name)) +} + +func testAccAwsOpsworksInstanceConfigUpdate(name string) string { + return fmt.Sprintf(` +resource "aws_security_group" "tf-ops-acc-web" { + name = "%s-web" + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_security_group" "tf-ops-acc-php" { + name = "%s-php" + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_opsworks_static_web_layer" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + + custom_security_group_ids = [ + "${aws_security_group.tf-ops-acc-web.id}", + ] +} + +resource "aws_opsworks_php_app_layer" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + + custom_security_group_ids = [ + "${aws_security_group.tf-ops-acc-php.id}", + ] +} + +resource "aws_opsworks_instance" "tf-acc" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + layer_ids = [ + "${aws_opsworks_static_web_layer.tf-acc.id}", + "${aws_opsworks_php_app_layer.tf-acc.id}", + ] + instance_type = "t2.small" + state = "stopped" + hostname = "tf-acc1" + os = "Amazon Linux 2015.09" +} + +%s + +`, name, name, testAccAwsOpsworksStackConfigVpcCreate(name)) +} diff --git a/website/source/docs/providers/aws/r/opsworks_instance.html.markdown b/website/source/docs/providers/aws/r/opsworks_instance.html.markdown new file mode 100644 index 000000000000..20b03c2dc665 --- /dev/null +++ b/website/source/docs/providers/aws/r/opsworks_instance.html.markdown @@ -0,0 +1,133 @@ +--- +layout: "aws" +page_title: "AWS: aws_opsworks_instance" +sidebar_current: "docs-aws-resource-opsworks-instance" +description: |- + Provides an OpsWorks instance resource. +--- + +# aws\_opsworks\_instance + +Provides an OpsWorks instance resource. + +## Example Usage + +``` +resource "aws_opsworks_instance" "my-instance" { + stack_id = "${aws_opsworks_stack.my-stack.id}" + layer_ids = [ + "${aws_opsworks_custom_layer.my-layer.id}", + ] + instance_type = "t2.micro" + os = "Amazon Linux 2015.09" + state = "stopped" +``` + +## Argument Reference + +The following arguments are supported: + +* `instance_type` - (Required) The type of instance to start +* `stack_id` - (Required) The id of the stack the instance will belong to. +* `layer_ids` - (Required) The ids of the layers the instance will belong to. +* `state` - (Optional) The desired state of the instance. Can be either `"running"` or `"stopped"`. +* `install_updates_on_boot` - (Optional) Controls where to install OS and package updates when the instance boots. Defaults to `true`. +* `auto_scaling_type` - (Optional) Creates load-based or time-based instances. If set, can be either: `"load"` or `"timer"`. +* `availability_zone` - (Optional) Name of the availability zone where instances will be created + by default. +* `ebs_optimized` - (Optional) If true, the launched EC2 instance will be EBS-optimized. +* `hostname` - (Optional) The instance's host name. +* `architecture` - (Optional) Machine architecture for created instances. Can be either `"x86_64"` (the default) or `"i386"` +* `ami_id` - (Optional) The AMI to use for the instance. If an AMI is specified, `os` must be `"Custom"`. +* `os` - (Optional) Name of operating system that will be installed. +* `root_device_type` - (Optional) Name of the type of root device instances will have by default. Can be either `"ebs"` or `"instance-store"` +* `ssh_key_name` - (Optional) Name of the SSH keypair that instances will have by default. +* `agent_version` - (Optional) The AWS OpsWorks agent to install. Defaults to `"INHERIT"`. +* `subnet_id` - (Optional) Subnet ID to attach to +* `virtualization_type` - (Optional) Keyword to choose what virtualization mode created instances + will use. Can be either `"paravirtual"` or `"hvm"`. +* `root_block_device` - (Optional) Customize details about the root block + device of the instance. See [Block Devices](#block-devices) below for details. +* `ebs_block_device` - (Optional) Additional EBS block devices to attach to the + instance. See [Block Devices](#block-devices) below for details. +* `ephemeral_block_device` - (Optional) Customize Ephemeral (also known as + "Instance Store") volumes on the instance. See [Block Devices](#block-devices) below for details. + + + +## Block devices + +Each of the `*_block_device` attributes controls a portion of the AWS +Instance's "Block Device Mapping". It's a good idea to familiarize yourself with [AWS's Block Device +Mapping docs](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html) +to understand the implications of using these attributes. + +The `root_block_device` mapping supports the following: + +* `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`, + or `"io1"`. (Default: `"standard"`). +* `volume_size` - (Optional) The size of the volume in gigabytes. +* `iops` - (Optional) The amount of provisioned + [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html). + This must be set with a `volume_type` of `"io1"`. +* `delete_on_termination` - (Optional) Whether the volume should be destroyed + on instance termination (Default: `true`). + +Modifying any of the `root_block_device` settings requires resource +replacement. + +Each `ebs_block_device` supports the following: + +* `device_name` - The name of the device to mount. +* `snapshot_id` - (Optional) The Snapshot ID to mount. +* `volume_type` - (Optional) The type of volume. Can be `"standard"`, `"gp2"`, + or `"io1"`. (Default: `"standard"`). +* `volume_size` - (Optional) The size of the volume in gigabytes. +* `iops` - (Optional) The amount of provisioned + [IOPS](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html). + This must be set with a `volume_type` of `"io1"`. +* `delete_on_termination` - (Optional) Whether the volume should be destroyed + on instance termination (Default: `true`). +* `encrypted` - (Optional) Enables [EBS + encryption](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html) + on the volume (Default: `false`). Cannot be used with `snapshot_id`. + +Modifying any `ebs_block_device` currently requires resource replacement. + +Each `ephemeral_block_device` supports the following: + +* `device_name` - The name of the block device to mount on the instance. +* `virtual_name` - The [Instance Store Device + Name](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#InstanceStoreDeviceNames) + (e.g. `"ephemeral0"`) + +Each AWS Instance type has a different set of Instance Store block devices +available for attachment. AWS [publishes a +list](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#StorageOnInstanceTypes) +of which ephemeral devices are available on each type. The devices are always +identified by the `virtual_name` in the format `"ephemeral{0..N}"`. + +~> **NOTE:** Currently, changes to `*_block_device` configuration of _existing_ +resources cannot be automatically detected by Terraform. After making updates +to block device configuration, resource recreation can be manually triggered by +using the [`taint` command](/docs/commands/taint.html). + + +## Attributes Reference + +The following attributes are exported: + +* `id` - The id of the OpsWorks instance. +* `agent_version` - The AWS OpsWorks agent version. +* `availability_zone` - The availability zone of the instance. +* `ssh_key_name` - The key name of the instance +* `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this + is only available if you've enabled DNS hostnames for your VPC +* `public_ip` - The public IP address assigned to the instance, if applicable. +* `private_dns` - The private DNS name assigned to the instance. Can only be + used inside the Amazon EC2, and only available if you've enabled DNS hostnames + for your VPC +* `private_ip` - The private IP address assigned to the instance +* `subnet_id` - The VPC subnet ID. +* `security_group_ids` - The associated security groups. + diff --git a/website/source/layouts/aws.erb b/website/source/layouts/aws.erb index 6887917c9dfd..689477c3b61f 100644 --- a/website/source/layouts/aws.erb +++ b/website/source/layouts/aws.erb @@ -458,6 +458,10 @@ aws_opsworks_haproxy_layer + > + aws_opsworks_instance + + > aws_opsworks_java_app_layer From 88de250615972584cdc480371b1a613d22a52c0e Mon Sep 17 00:00:00 2001 From: Jeff Tang Date: Thu, 24 Mar 2016 08:08:01 -0400 Subject: [PATCH 002/665] style updates to documentation and nil checks --- .../aws/resource_aws_opsworks_instance.go | 15 +++++++++++++++ .../aws/r/opsworks_instance.html.markdown | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_opsworks_instance.go b/builtin/providers/aws/resource_aws_opsworks_instance.go index dc4051f014bd..bf1dbfdf3066 100644 --- a/builtin/providers/aws/resource_aws_opsworks_instance.go +++ b/builtin/providers/aws/resource_aws_opsworks_instance.go @@ -510,8 +510,19 @@ func resourceAwsOpsworksInstanceRead(d *schema.ResourceData, meta interface{}) e return err } + // If nothing was found, then return no state + if len(resp.Instances) == 0 { + d.SetId("") + return nil + } instance := resp.Instances[0] + + if instance.InstanceId == nil { + d.SetId("") + return nil + } instanceId := *instance.InstanceId + d.SetId(instanceId) d.Set("agent_version", instance.AgentVersion) d.Set("ami_id", instance.AmiId) @@ -726,6 +737,10 @@ func resourceAwsOpsworksInstanceCreate(d *schema.ResourceData, meta interface{}) return err } + if resp.InstanceId == nil { + return fmt.Errorf("Error launching instance: no instance returned in response") + } + instanceId := *resp.InstanceId d.SetId(instanceId) d.Set("id", instanceId) diff --git a/website/source/docs/providers/aws/r/opsworks_instance.html.markdown b/website/source/docs/providers/aws/r/opsworks_instance.html.markdown index 20b03c2dc665..c855d559f28f 100644 --- a/website/source/docs/providers/aws/r/opsworks_instance.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_instance.html.markdown @@ -13,14 +13,17 @@ Provides an OpsWorks instance resource. ## Example Usage ``` -resource "aws_opsworks_instance" "my-instance" { +aws_opsworks_instance" "my-instance" { stack_id = "${aws_opsworks_stack.my-stack.id}" + layer_ids = [ "${aws_opsworks_custom_layer.my-layer.id}", ] + instance_type = "t2.micro" - os = "Amazon Linux 2015.09" - state = "stopped" + os = "Amazon Linux 2015.09" + state = "stopped" +} ``` ## Argument Reference From 41a8220e0fa821b748fb1fdfaa513d73f4f2f13c Mon Sep 17 00:00:00 2001 From: Jeff Tang Date: Fri, 11 Dec 2015 15:14:11 -0500 Subject: [PATCH 003/665] add custom_json for opsworks layers --- builtin/providers/aws/opsworks_layers.go | 22 +++++++++++++++++++ ...resource_aws_opsworks_custom_layer_test.go | 4 ++++ .../aws/r/opsworks_custom_layer.html.markdown | 1 + .../r/opsworks_ganglia_layer.html.markdown | 1 + .../r/opsworks_haproxy_layer.html.markdown | 1 + .../r/opsworks_java_app_layer.html.markdown | 1 + .../r/opsworks_memcached_layer.html.markdown | 1 + .../aws/r/opsworks_mysql_layer.html.markdown | 1 + .../r/opsworks_nodejs_app_layer.html.markdown | 1 + .../r/opsworks_php_app_layer.html.markdown | 1 + .../r/opsworks_rails_app_layer.html.markdown | 1 + .../aws/r/opsworks_stack.html.markdown | 1 + 12 files changed, 36 insertions(+) diff --git a/builtin/providers/aws/opsworks_layers.go b/builtin/providers/aws/opsworks_layers.go index 6eb6d1bddeab..1b0800348bfb 100644 --- a/builtin/providers/aws/opsworks_layers.go +++ b/builtin/providers/aws/opsworks_layers.go @@ -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") { diff --git a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go index 7dcff04ffa3f..4df71948445c 100644 --- a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go +++ b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown index 7f04202d4c79..b43ce8a2dd0a 100644 --- a/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_custom_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_ganglia_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_ganglia_layer.html.markdown index 29c8fc68e261..3425eb196e3d 100644 --- a/website/source/docs/providers/aws/r/opsworks_ganglia_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_ganglia_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_haproxy_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_haproxy_layer.html.markdown index 68b54a646f0c..baeff6172861 100644 --- a/website/source/docs/providers/aws/r/opsworks_haproxy_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_haproxy_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_java_app_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_java_app_layer.html.markdown index 0463fbba76aa..7d4b3eb232c9 100644 --- a/website/source/docs/providers/aws/r/opsworks_java_app_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_java_app_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_memcached_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_memcached_layer.html.markdown index 31d4728063e3..fcbcf16f8b3a 100644 --- a/website/source/docs/providers/aws/r/opsworks_memcached_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_memcached_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_mysql_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_mysql_layer.html.markdown index 0cc11b73f5d8..85033868646e 100644 --- a/website/source/docs/providers/aws/r/opsworks_mysql_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_mysql_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_nodejs_app_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_nodejs_app_layer.html.markdown index ea0fdeb9b401..e9ab9d597e3c 100644 --- a/website/source/docs/providers/aws/r/opsworks_nodejs_app_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_nodejs_app_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_php_app_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_php_app_layer.html.markdown index 7d5d8ab8f751..8335c4154d87 100644 --- a/website/source/docs/providers/aws/r/opsworks_php_app_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_php_app_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_rails_app_layer.html.markdown b/website/source/docs/providers/aws/r/opsworks_rails_app_layer.html.markdown index 27ea7a979c7c..3d2c10fb5df5 100644 --- a/website/source/docs/providers/aws/r/opsworks_rails_app_layer.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_rails_app_layer.html.markdown @@ -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 diff --git a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown index d664ca1a9520..b55fa9dffe60 100644 --- a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown @@ -51,6 +51,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: From 23b953eea3985f962b65d8a285cdf4a023cd7619 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Tue, 5 Apr 2016 15:09:41 +0000 Subject: [PATCH 004/665] provider/openstack: Allow resizing when Flavor Name changes Previously, resizing would only work if the flavor_id changed and would create an error if the flavor_name changes. This commit fixes this behavior. It also quickly refactors the getFlavorID function to use Gophercloud's IDFromName function. getFlavorID was the basis of IDFromName so the exact same code is used. Fixes #5780 --- .../resource_openstack_compute_instance_v2.go | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index 2b621c92d616..b863c5114648 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -725,12 +725,20 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e } if d.HasChange("flavor_id") || d.HasChange("flavor_name") { - flavorId, err := getFlavorID(computeClient, d) - if err != nil { - return err + var newFlavorId string + var err error + if d.HasChange("flavor_id") { + newFlavorId = d.Get("flavor_id").(string) + } else { + newFlavorName := d.Get("flavor_name").(string) + newFlavorId, err = flavors.IDFromName(computeClient, newFlavorName) + if err != nil { + return err + } } + resizeOpts := &servers.ResizeOpts{ - FlavorRef: flavorId, + FlavorRef: newFlavorId, } log.Printf("[DEBUG] Resize configuration: %#v", resizeOpts) err = servers.Resize(computeClient, d.Id(), resizeOpts).ExtractErr() @@ -1258,35 +1266,8 @@ func getFlavorID(client *gophercloud.ServiceClient, d *schema.ResourceData) (str return flavorId, nil } - flavorCount := 0 flavorName := d.Get("flavor_name").(string) - if flavorName != "" { - pager := flavors.ListDetail(client, nil) - pager.EachPage(func(page pagination.Page) (bool, error) { - flavorList, err := flavors.ExtractFlavors(page) - if err != nil { - return false, err - } - - for _, f := range flavorList { - if f.Name == flavorName { - flavorCount++ - flavorId = f.ID - } - } - return true, nil - }) - - switch flavorCount { - case 0: - return "", fmt.Errorf("Unable to find flavor: %s", flavorName) - case 1: - return flavorId, nil - default: - return "", fmt.Errorf("Found %d flavors matching %s", flavorCount, flavorName) - } - } - return "", fmt.Errorf("Neither a flavor ID nor a flavor name were able to be determined.") + return flavors.IDFromName(client, flavorName) } func resourceComputeVolumeAttachmentHash(v interface{}) int { From cf607e8a5871aef57d2bdd3caef2b48f8e71b2d4 Mon Sep 17 00:00:00 2001 From: Jeff LaPlante Date: Tue, 5 Apr 2016 09:12:45 -0700 Subject: [PATCH 005/665] Added Group attribute to cloudstack instance resource --- .../cloudstack/resource_cloudstack_instance.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_instance.go b/builtin/providers/cloudstack/resource_cloudstack_instance.go index 05898dc23b4c..315b99ad3e75 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_instance.go +++ b/builtin/providers/cloudstack/resource_cloudstack_instance.go @@ -93,6 +93,12 @@ func resourceCloudStackInstance() *schema.Resource { Optional: true, Default: false, }, + + "group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, }, } } @@ -193,6 +199,11 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) p.SetUserdata(ud) } + // If there is a group supplied, add it to the parameter struct + if group, ok := d.GetOk("group"); ok { + p.SetGroup(group.(string)) + } + // Create the new instance r, err := cs.VirtualMachine.DeployVirtualMachine(p) if err != nil { From ba4ec0097a47820db3bd686fdb708eca3b717d74 Mon Sep 17 00:00:00 2001 From: Jeff LaPlante Date: Tue, 5 Apr 2016 09:21:23 -0700 Subject: [PATCH 006/665] fixed formatting --- .../cloudstack/resource_cloudstack_instance.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_instance.go b/builtin/providers/cloudstack/resource_cloudstack_instance.go index 315b99ad3e75..75b1ce06ede0 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_instance.go +++ b/builtin/providers/cloudstack/resource_cloudstack_instance.go @@ -94,11 +94,11 @@ func resourceCloudStackInstance() *schema.Resource { Default: false, }, - "group": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, + "group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, }, } } @@ -199,10 +199,10 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) p.SetUserdata(ud) } - // If there is a group supplied, add it to the parameter struct - if group, ok := d.GetOk("group"); ok { - p.SetGroup(group.(string)) - } + // If there is a group supplied, add it to the parameter struct + if group, ok := d.GetOk("group"); ok { + p.SetGroup(group.(string)) + } // Create the new instance r, err := cs.VirtualMachine.DeployVirtualMachine(p) From b857bd1ce9ccc7e58b64ce4c2076ac742de2f810 Mon Sep 17 00:00:00 2001 From: Jeff Tang Date: Thu, 24 Mar 2016 16:46:45 -0400 Subject: [PATCH 007/665] add TestCheckExists/TestCheckAttributes for opsworks instance --- .../resource_aws_opsworks_instance_test.go | 69 ++++++++++++++++++- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_opsworks_instance_test.go b/builtin/providers/aws/resource_aws_opsworks_instance_test.go index 82d02b63e57b..e79f8bb45dfc 100644 --- a/builtin/providers/aws/resource_aws_opsworks_instance_test.go +++ b/builtin/providers/aws/resource_aws_opsworks_instance_test.go @@ -12,11 +12,9 @@ import ( "github.com/hashicorp/terraform/terraform" ) -// These tests assume the existence of predefined Opsworks IAM roles named `aws-opsworks-ec2-role` -// and `aws-opsworks-service-role`. - func TestAccAWSOpsworksInstance(t *testing.T) { stackName := fmt.Sprintf("tf-%d", acctest.RandInt()) + var opsinst opsworks.Instance resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -25,6 +23,9 @@ func TestAccAWSOpsworksInstance(t *testing.T) { resource.TestStep{ Config: testAccAwsOpsworksInstanceConfigCreate(stackName), Check: resource.ComposeTestCheckFunc( + testAccCheckAWSOpsworksInstanceExists( + "aws_opsworks_instance.tf-acc", &opsinst), + testAccCheckAWSOpsworksInstanceAttributes(&opsinst), resource.TestCheckResourceAttr( "aws_opsworks_instance.tf-acc", "hostname", "tf-acc1", ), @@ -57,6 +58,9 @@ func TestAccAWSOpsworksInstance(t *testing.T) { resource.TestStep{ Config: testAccAwsOpsworksInstanceConfigUpdate(stackName), Check: resource.ComposeTestCheckFunc( + testAccCheckAWSOpsworksInstanceExists( + "aws_opsworks_instance.tf-acc", &opsinst), + testAccCheckAWSOpsworksInstanceAttributes(&opsinst), resource.TestCheckResourceAttr( "aws_opsworks_instance.tf-acc", "hostname", "tf-acc1", ), @@ -75,6 +79,65 @@ func TestAccAWSOpsworksInstance(t *testing.T) { }) } +func testAccCheckAWSOpsworksInstanceExists( + n string, opsinst *opsworks.Instance) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("No Opsworks Instance is set") + } + + conn := testAccProvider.Meta().(*AWSClient).opsworksconn + + params := &opsworks.DescribeInstancesInput{ + InstanceIds: []*string{&rs.Primary.ID}, + } + resp, err := conn.DescribeInstances(params) + + if err != nil { + return err + } + + if v := len(resp.Instances); v != 1 { + return fmt.Errorf("Expected 1 request returned, got %d", v) + } + + *opsinst = *resp.Instances[0] + + return nil + } +} + +func testAccCheckAWSOpsworksInstanceAttributes( + opsinst *opsworks.Instance) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Depending on the timing, the state could be requested or stopped + if *opsinst.Status != "stopped" && *opsinst.Status != "requested" { + return fmt.Errorf("Unexpected request status: %s", *opsinst.Status) + } + if *opsinst.AvailabilityZone != "us-west-2a" { + return fmt.Errorf("Unexpected availability zone: %s", *opsinst.AvailabilityZone) + } + if *opsinst.Architecture != "x86_64" { + return fmt.Errorf("Unexpected architecture: %s", *opsinst.Architecture) + } + if *opsinst.InfrastructureClass != "ec2" { + return fmt.Errorf("Unexpected infrastructure class: %s", *opsinst.InfrastructureClass) + } + if *opsinst.RootDeviceType != "ebs" { + return fmt.Errorf("Unexpected root device type: %s", *opsinst.RootDeviceType) + } + if *opsinst.VirtualizationType != "hvm" { + return fmt.Errorf("Unexpected virtualization type: %s", *opsinst.VirtualizationType) + } + return nil + } +} + func testAccCheckAwsOpsworksInstanceDestroy(s *terraform.State) error { opsworksconn := testAccProvider.Meta().(*AWSClient).opsworksconn for _, rs := range s.RootModule().Resources { From 320773d6c172eb98e66d76526aa4dc8be72130bc Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 5 Apr 2016 18:42:09 -0700 Subject: [PATCH 008/665] command: delete unused class --- command/config.go | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 command/config.go diff --git a/command/config.go b/command/config.go deleted file mode 100644 index c01016df7e1b..000000000000 --- a/command/config.go +++ /dev/null @@ -1,25 +0,0 @@ -package command - -import ( - "github.com/hashicorp/terraform/terraform" - "github.com/mitchellh/cli" -) - -// Config is a structure used to configure many commands with Terraform -// configurations. -type Config struct { - Hooks []terraform.Hook - Providers map[string]terraform.ResourceProviderFactory - Ui cli.Ui -} - -func (c *Config) ContextOpts() *terraform.ContextOpts { - hooks := make([]terraform.Hook, len(c.Hooks)+1) - copy(hooks, c.Hooks) - hooks[len(c.Hooks)] = &UiHook{Ui: c.Ui} - - return &terraform.ContextOpts{ - Hooks: hooks, - Providers: c.Providers, - } -} From ad761f338d20ae2b10cb30d1298b705dccd67d14 Mon Sep 17 00:00:00 2001 From: Hector Rivas Gandara Date: Wed, 6 Apr 2016 16:28:24 +0100 Subject: [PATCH 009/665] provider/aws: Doc cloudwatch SNS and lambda perms Documentation for `aws_cloudwatch_event_target` to warn that in order to be able to have your AWS Lambda function or SNS topic invoked by a CloudWatch Events rule, you must setup the right permissions using `aws_lambda_permission` or `aws_sns_topic.policy` --- .../providers/aws/r/cloudwatch_event_target.html.markdown | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/website/source/docs/providers/aws/r/cloudwatch_event_target.html.markdown b/website/source/docs/providers/aws/r/cloudwatch_event_target.html.markdown index b8248548c8db..2afe5facd1b2 100644 --- a/website/source/docs/providers/aws/r/cloudwatch_event_target.html.markdown +++ b/website/source/docs/providers/aws/r/cloudwatch_event_target.html.markdown @@ -46,11 +46,16 @@ resource "aws_kinesis_stream" "test_stream" { ## Argument Reference -> **Note:** `input` and `input_path` are mutually exclusive options. +-> **Note:** In order to be able to have your AWS Lambda function or + SNS topic invoked by a CloudWatch Events rule, you must setup the right permissions + using [`aws_lambda_permission`](https://www.terraform.io/docs/providers/aws/r/lambda_permission.html) + or [`aws_sns_topic.policy`](https://www.terraform.io/docs/providers/aws/r/sns_topic.html#policy). + More info here [here](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/EventsResourceBasedPermissions.html). The following arguments are supported: * `rule` - (Required) The name of the rule you want to add targets to. -* `target_id` - (Optional) The unique target assignment ID. If missing, will generate a random, unique id. +* `target_id` - (Optional) The unique target assignment ID. If missing, will generate a random, unique id. * `arn` - (Required) The Amazon Resource Name (ARN) associated of the target. * `input` - (Optional) Valid JSON text passed to the target. * `input_path` - (Optional) The value of the [JSONPath](http://goessner.net/articles/JsonPath/) From f739ef984978ed7838898036b49359737d789410 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 6 Apr 2016 09:34:10 -0700 Subject: [PATCH 010/665] Human-readable error for failure to read EC2 volume Previously the format string was using %#v, which prints the whole data structure given. Instead we want to use %s to get the string representation of the error. This fixes #6038. --- builtin/providers/aws/resource_aws_ebs_volume.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_ebs_volume.go b/builtin/providers/aws/resource_aws_ebs_volume.go index 5abea1f2ffe2..8dfbd0cf3cc1 100644 --- a/builtin/providers/aws/resource_aws_ebs_volume.go +++ b/builtin/providers/aws/resource_aws_ebs_volume.go @@ -186,7 +186,7 @@ func resourceAwsEbsVolumeRead(d *schema.ResourceData, meta interface{}) error { d.SetId("") return nil } - return fmt.Errorf("Error reading EC2 volume %s: %#v", d.Id(), err) + return fmt.Errorf("Error reading EC2 volume %s: %s", d.Id(), err) } return readVolume(d, response.Volumes[0]) From e698822be50c90b4ac9d20fd91791befdfcb9c7f Mon Sep 17 00:00:00 2001 From: David Harris Date: Wed, 6 Apr 2016 10:35:07 -0600 Subject: [PATCH 011/665] provider/aws: Renaming `option_settings` attribute to `setting`. Added test to verify that settings are applied to template. Fixes #6035 --- ...lastic_beanstalk_configuration_template.go | 8 ++-- ...c_beanstalk_configuration_template_test.go | 45 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go index 1f3f91e84b1f..15cb8543a59d 100644 --- a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go +++ b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go @@ -132,7 +132,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateUpdate(d *schema.ResourceDa } } - if d.HasChange("option_settings") { + if d.HasChange("setting") { if err := resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn, d); err != nil { return err } @@ -152,7 +152,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateDescriptionUpdate(conn *ela } func resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error { - if d.HasChange("option_settings") { + if d.HasChange("setting") { _, err := conn.ValidateConfigurationSettings(&elasticbeanstalk.ValidateConfigurationSettingsInput{ ApplicationName: aws.String(d.Get("application").(string)), TemplateName: aws.String(d.Get("name").(string)), @@ -162,7 +162,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn * return err } - o, n := d.GetChange("option_settings") + o, n := d.GetChange("setting") if o == nil { o = new(schema.Set) } @@ -211,7 +211,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateDelete(d *schema.ResourceDa } func gatherOptionSettings(d *schema.ResourceData) []*elasticbeanstalk.ConfigurationOptionSetting { - optionSettingsSet, ok := d.Get("option_settings").(*schema.Set) + optionSettingsSet, ok := d.Get("setting").(*schema.Set) if !ok || optionSettingsSet == nil { optionSettingsSet = new(schema.Set) } diff --git a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go index 17f1a6ca7a05..0a26242b73e7 100644 --- a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go +++ b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go @@ -48,6 +48,28 @@ func TestAccAWSBeanstalkConfigurationTemplate_VPC(t *testing.T) { }) } +func TestAccAWSBeanstalkConfigurationTemplate_Setting(t *testing.T) { + var config elasticbeanstalk.ConfigurationSettingsDescription + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckBeanstalkConfigurationTemplateDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccBeanstalkConfigurationTemplateConfig_Setting(acctest.RandString(5)), + Check: resource.ComposeTestCheckFunc( + testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config), + resource.TestCheckResourceAttr( + "aws_elastic_beanstalk_configuration_template.tf_template", "setting.#", "1"), + resource.TestCheckResourceAttr( + "aws_elastic_beanstalk_configuration_template.tf_template", "setting.4112217815.value", "m1.small"), + ), + }, + }, + }) +} + func testAccCheckBeanstalkConfigurationTemplateDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn @@ -177,3 +199,26 @@ resource "aws_elastic_beanstalk_configuration_template" "tf_template" { } `, name, name) } + +func testAccBeanstalkConfigurationTemplateConfig_Setting(name string) string { + return fmt.Sprintf(` +resource "aws_elastic_beanstalk_application" "tftest" { + name = "tf-test-%s" + description = "tf-test-desc" +} + +resource "aws_elastic_beanstalk_configuration_template" "tf_template" { + name = "tf-test-%s" + application = "${aws_elastic_beanstalk_application.tftest.name}" + + solution_stack_name = "64bit Amazon Linux running Python" + + setting { + namespace = "aws:autoscaling:launchconfiguration" + name = "InstanceType" + value = "m1.small" + } + +} +`, name, name) +} From ca4eed7c0e5323bca2442e5841e18f104cda14e1 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 6 Apr 2016 09:40:22 -0700 Subject: [PATCH 012/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac92f648d560..3f454b3e8c8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ BUG FIXES: * provider/aws: Remove CloudTrail Trail from state if not found [GH-6024] * provider/aws: Report better error message in `aws_route53_record` when `set_identifier` is required [GH-5777] * provider/aws: set ASG `health_check_grace_period` default to 300 [GH-5830] + * provider/aws: Show human-readable error message when failing to read an EBS volume [GH-6038] * provider/azurerm: Fix detection of `azurerm_storage_account` resources removed manually [GH-5878] * provider/docker: Docker Image will be deleted on destroy [GH-5801] From be0ebbc22e82932f1b7f697e9580779edd8db2ab Mon Sep 17 00:00:00 2001 From: Jeff Tang Date: Wed, 6 Apr 2016 15:57:14 -0400 Subject: [PATCH 013/665] Handle race condition with IAM role permissions --- builtin/providers/aws/resource_aws_opsworks_stack.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_opsworks_stack.go b/builtin/providers/aws/resource_aws_opsworks_stack.go index c021f16a999f..61ceb7a1a4c8 100644 --- a/builtin/providers/aws/resource_aws_opsworks_stack.go +++ b/builtin/providers/aws/resource_aws_opsworks_stack.go @@ -341,7 +341,8 @@ func resourceAwsOpsworksStackCreate(d *schema.ResourceData, meta interface{}) er // Service Role Arn: [...] is not yet propagated, please try again in a couple of minutes propErr := "not yet propagated" trustErr := "not the necessary trust relationship" - if opserr.Code() == "ValidationException" && (strings.Contains(opserr.Message(), trustErr) || strings.Contains(opserr.Message(), propErr)) { + validateErr := "validate IAM role permission" + if opserr.Code() == "ValidationException" && (strings.Contains(opserr.Message(), trustErr) || strings.Contains(opserr.Message(), propErr) || strings.Contains(opserr.Message(), validateErr)) { log.Printf("[INFO] Waiting for service IAM role to propagate") return resource.RetryableError(cerr) } From d15a0eb752af917e966cdd2f1b3815455034ff4b Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Wed, 6 Apr 2016 13:11:46 -0600 Subject: [PATCH 014/665] provider/openstack: Fix Disabling DHCP on Subnets This commit fixes a bug where "false" was not correctly being passed to the subnet creation and therefore enabling DHCP on all subnets. --- ...resource_openstack_networking_subnet_v2.go | 8 ++-- ...rce_openstack_networking_subnet_v2_test.go | 42 ++++++++++++++++--- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go index a9eafa51333f..cef09641b791 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go @@ -117,6 +117,8 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error creating OpenStack networking client: %s", err) } + enableDHCP := d.Get("enable_dhcp").(bool) + createOpts := subnets.CreateOpts{ NetworkID: d.Get("network_id").(string), CIDR: d.Get("cidr").(string), @@ -127,11 +129,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) IPVersion: d.Get("ip_version").(int), DNSNameservers: resourceSubnetDNSNameserversV2(d), HostRoutes: resourceSubnetHostRoutesV2(d), - } - - if raw, ok := d.GetOk("enable_dhcp"); ok { - value := raw.(bool) - createOpts.EnableDHCP = &value + EnableDHCP: &enableDHCP, } log.Printf("[DEBUG] Create Options: %#v", createOpts) diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go index 0b4b9427d937..1931d80ebc57 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go @@ -29,6 +29,26 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "name", "tf-test-subnet"), resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"), + resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "false"), + ), + }, + }, + }) +} + +func TestAccNetworkingV2Subnet_enableDHCP(t *testing.T) { + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SubnetDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Subnet_enableDHCP, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet), + resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"), ), }, }, @@ -90,28 +110,38 @@ func testAccCheckNetworkingV2SubnetExists(t *testing.T, n string, subnet *subnet var testAccNetworkingV2Subnet_basic = fmt.Sprintf(` resource "openstack_networking_network_v2" "network_1" { - region = "%s" name = "network_1" admin_state_up = "true" } resource "openstack_networking_subnet_v2" "subnet_1" { - region = "%s" network_id = "${openstack_networking_network_v2.network_1.id}" cidr = "192.168.199.0/24" - }`, OS_REGION_NAME, OS_REGION_NAME) + }`) var testAccNetworkingV2Subnet_update = fmt.Sprintf(` resource "openstack_networking_network_v2" "network_1" { - region = "%s" name = "network_1" admin_state_up = "true" } resource "openstack_networking_subnet_v2" "subnet_1" { - region = "%s" name = "tf-test-subnet" network_id = "${openstack_networking_network_v2.network_1.id}" cidr = "192.168.199.0/24" gateway_ip = "192.168.199.1" - }`, OS_REGION_NAME, OS_REGION_NAME) + }`) + +var testAccNetworkingV2Subnet_enableDHCP = fmt.Sprintf(` + resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" + } + + resource "openstack_networking_subnet_v2" "subnet_1" { + name = "tf-test-subnet" + network_id = "${openstack_networking_network_v2.network_1.id}" + cidr = "192.168.199.0/24" + gateway_ip = "192.168.199.1" + enable_dhcp = true + }`) From 662dc9f49c532d4913623bf6868055006b0702a3 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Wed, 6 Apr 2016 16:54:40 -0500 Subject: [PATCH 015/665] update docs on required parameter for api_gateway_integration * update docs on required parameter for api_gateway_integration This parameter was required for lambda integration. Otherwise, ` Error creating API Gateway Integration: BadRequestException: Enumeration value for HttpMethod must be non-empty` * documentation: Including the AWS type on the api_gateway_integration docs --- .../docs/providers/aws/r/api_gateway_integration.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown b/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown index cf2b90d3a12b..028d6b28cc82 100644 --- a/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown +++ b/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown @@ -52,7 +52,7 @@ The following arguments are supported: e.g. `arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:012345678901:function:my-func/invocations` * `credentials` - (Optional) The credentials required for the integration. For `AWS` integrations, 2 options are available. To specify an IAM Role for Amazon API Gateway to assume, use the role's ARN. To require that the caller's identity be passed through from the request, specify the string `arn:aws:iam::\*:user/\*`. * `integration_http_method` - (Optional) The integration HTTP method - (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`). + (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`). **Required** if `type` is `AWS` or `HTTP`. Not all methods are compatible with all `AWS` integrations. e.g. Lambda function [can only be invoked](https://github.com/awslabs/aws-apigateway-importer/issues/9#issuecomment-129651005) via `POST`. * `request_templates` - (Optional) A map of the integration's request templates. From 4fde3b2be9f5230c8d83b8e1bae160d8e60f39f6 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 7 Apr 2016 10:26:01 -0400 Subject: [PATCH 016/665] Capitalize the H in GitHub GitHub really doesn't like when you make the H lowercase, it violates their brand guidelines and they won't help promote anything that doesn't use the capital H. --- .../docs/providers/github/index.html.markdown | 16 ++++++++-------- .../providers/github/r/membership.html.markdown | 6 +++--- .../docs/providers/github/r/team.html.markdown | 6 +++--- .../github/r/team_membership.html.markdown | 8 ++++---- .../github/r/team_repository.html.markdown | 8 ++++---- website/source/layouts/docs.erb | 2 +- website/source/layouts/github.erb | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/website/source/docs/providers/github/index.html.markdown b/website/source/docs/providers/github/index.html.markdown index e7d11056fb1c..590e93056f08 100644 --- a/website/source/docs/providers/github/index.html.markdown +++ b/website/source/docs/providers/github/index.html.markdown @@ -1,16 +1,16 @@ --- layout: "github" -page_title: "Provider: Github" +page_title: "Provider: GitHub" sidebar_current: "docs-github-index" description: |- - The Github provider is used to interact with Github organization resources. + The GitHub provider is used to interact with GitHub organization resources. --- -# Github Provider +# GitHub Provider -The Github provider is used to interact with Github organization resources. +The GitHub provider is used to interact with GitHub organization resources. -The provider allows you to manage your Github organization's members and teams easily. +The provider allows you to manage your GitHub organization's members and teams easily. It needs to be configured with the proper credentials before it can be used. Use the navigation to the left to read about the available resources. @@ -18,7 +18,7 @@ Use the navigation to the left to read about the available resources. ## Example Usage ``` -# Configure the Github Provider +# Configure the GitHub Provider provider "github" { token = "${var.github_token}" organization = "${var.github_organization}" @@ -34,9 +34,9 @@ resource "github_membership" "membership_for_user_x" { The following arguments are supported in the `provider` block: -* `token` - (Optional) This is the Github personal access token. It must be provided, but +* `token` - (Optional) This is the GitHub personal access token. It must be provided, but it can also be sourced from the `GITHUB_TOKEN` environment variable. -* `organization` - (Optional) This is the target Github organization to manage. The account +* `organization` - (Optional) This is the target GitHub organization to manage. The account corresponding to the token will need "owner" privileges for this organization. It must be provided, but it can also be sourced from the `GITHUB_ORGANIZATION` environment variable. diff --git a/website/source/docs/providers/github/r/membership.html.markdown b/website/source/docs/providers/github/r/membership.html.markdown index 5f73e2132b82..bc0d9b6032cc 100644 --- a/website/source/docs/providers/github/r/membership.html.markdown +++ b/website/source/docs/providers/github/r/membership.html.markdown @@ -1,14 +1,14 @@ --- layout: "github" -page_title: "Github: github_membership" +page_title: "GitHub: github_membership" sidebar_current: "docs-github-resource-membership" description: |- - Provides a Github membership resource. + Provides a GitHub membership resource. --- # github\_membership -Provides a Github membership resource. +Provides a GitHub membership resource. This resource allows you to add/remove users from your organization. When applied, an invitation will be sent to the user to become part of the organization. When diff --git a/website/source/docs/providers/github/r/team.html.markdown b/website/source/docs/providers/github/r/team.html.markdown index d81533a73411..4e4ee13dd4dd 100644 --- a/website/source/docs/providers/github/r/team.html.markdown +++ b/website/source/docs/providers/github/r/team.html.markdown @@ -1,14 +1,14 @@ --- layout: "github" -page_title: "Github: github_team" +page_title: "GitHub: github_team" sidebar_current: "docs-github-resource-team" description: |- - Provides a Github team resource. + Provides a GitHub team resource. --- # github\_team -Provides a Github team resource. +Provides a GitHub team resource. This resource allows you to add/remove teams from your organization. When applied, a new team will be created. When destroyed, that team will be removed. diff --git a/website/source/docs/providers/github/r/team_membership.html.markdown b/website/source/docs/providers/github/r/team_membership.html.markdown index 6161068a6db0..e87ab8af0344 100644 --- a/website/source/docs/providers/github/r/team_membership.html.markdown +++ b/website/source/docs/providers/github/r/team_membership.html.markdown @@ -1,14 +1,14 @@ --- layout: "github" -page_title: "Github: github_team_membership" +page_title: "GitHub: github_team_membership" sidebar_current: "docs-github-resource-team-membership" description: |- - Provides a Github team membership resource. + Provides a GitHub team membership resource. --- # github\_team_membership -Provides a Github team membership resource. +Provides a GitHub team membership resource. This resource allows you to add/remove users from teams in your organization. When applied, the user will be added to the team. If the user hasn't accepted their invitation to the @@ -40,7 +40,7 @@ resource "github_team_membership" "some_team_membership" { The following arguments are supported: -* `team_id` - (Required) The Github team id +* `team_id` - (Required) The GitHub team id * `username` - (Required) The user to add to the team. * `role` - (Optional) The role of the user within the team. Must be one of `member` or `maintainer`. Defaults to `member`. diff --git a/website/source/docs/providers/github/r/team_repository.html.markdown b/website/source/docs/providers/github/r/team_repository.html.markdown index c62b58a34f5e..fcc1bc6da1f8 100644 --- a/website/source/docs/providers/github/r/team_repository.html.markdown +++ b/website/source/docs/providers/github/r/team_repository.html.markdown @@ -1,14 +1,14 @@ --- layout: "github" -page_title: "Github: github_team_repository" +page_title: "GitHub: github_team_repository" sidebar_current: "docs-github-resource-team-repository" description: |- - Provides a Github team repository resource. + Provides a GitHub team repository resource. --- # github\_team_repository -Provides a Github team repository resource. +Provides a GitHub team repository resource. This resource allows you to add/remove repositories from teams in your organization. When applied, the repository will be added to the team. When destroyed, the repository will be removed from the team. @@ -33,7 +33,7 @@ resource "github_team_repository" "some_team_repo" { The following arguments are supported: -* `team_id` - (Required) The Github team id +* `team_id` - (Required) The GitHub team id * `repository` - (Required) The repository to add to the team. * `permission` - (Optional) The permissions of team members regarding the repository. Must be one of `pull`, `push`, or `admin`. Defaults to `pull`. diff --git a/website/source/layouts/docs.erb b/website/source/layouts/docs.erb index aea3fc3962c9..510637114775 100644 --- a/website/source/layouts/docs.erb +++ b/website/source/layouts/docs.erb @@ -194,7 +194,7 @@ > - Github + GitHub > diff --git a/website/source/layouts/github.erb b/website/source/layouts/github.erb index a49aecfe47b3..54dbe960cfc9 100644 --- a/website/source/layouts/github.erb +++ b/website/source/layouts/github.erb @@ -7,7 +7,7 @@ > - Github Provider + GitHub Provider > From 54132c16b46ab676bbdce08d789994b2ce4af209 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 7 Apr 2016 10:39:08 -0500 Subject: [PATCH 017/665] website: force JS/CSS mime-types on deploy Should fix occassional issues with application/octet-stream mime type assets breaking JS/CSS on site. --- website/scripts/deploy.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/scripts/deploy.sh b/website/scripts/deploy.sh index 9376c39cdf29..9665e8cda311 100755 --- a/website/scripts/deploy.sh +++ b/website/scripts/deploy.sh @@ -61,6 +61,15 @@ if [ -z "$NO_UPLOAD" ]; then --add-header="Cache-Control: max-age=31536000" \ --add-header="x-amz-meta-surrogate-key: site-$PROJECT" \ sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/" + + # The s3cmd guessed mime type for text files is often wrong. This is + # problematic for JS/CSS, so force their mime types to be correct. + s3cmd \ + --mime-type="application/javascript" \ + modify "s3://hc-sites/$PROJECT/latest/assets/javascripts/*.js" + s3cmd \ + --mime-type="text/css" \ + modify "s3://hc-sites/$PROJECT/latest/assets/stylesheets/*.css" fi # Perform a soft-purge of the surrogate key. From 4fbe7cb361b5700535684a5b08bfe0596af44377 Mon Sep 17 00:00:00 2001 From: Matthew Walter Date: Thu, 7 Apr 2016 12:26:43 -0400 Subject: [PATCH 018/665] Corrected typo in AzureRM template deployment docs (#6068) --- .../docs/providers/azurerm/r/template_deployment.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/providers/azurerm/r/template_deployment.html.markdown b/website/source/docs/providers/azurerm/r/template_deployment.html.markdown index 5b3a6695a9f9..4357a7616221 100644 --- a/website/source/docs/providers/azurerm/r/template_deployment.html.markdown +++ b/website/source/docs/providers/azurerm/r/template_deployment.html.markdown @@ -86,7 +86,7 @@ The following arguments are supported: create the template deployment. * `template_body` - (Optional) Specifies the JSON definition for the template. * `parameters` - (Optional) Specifies the name and value pairs that define the deployment parameters for the template. -* `deploymnet_mode` - (Optional) Specifies the mode that is used to deploy resources. This value could be either `Incremental` or `Complete`. +* `deployment_mode` - (Optional) Specifies the mode that is used to deploy resources. This value could be either `Incremental` or `Complete`. ## Attributes Reference From bf45bfb68553429bcf572d4167bc13a7ca76f7c9 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 7 Apr 2016 13:01:01 -0500 Subject: [PATCH 019/665] website: Handle SVGs in deployment mime-type fixup as well --- website/scripts/deploy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/website/scripts/deploy.sh b/website/scripts/deploy.sh index 9665e8cda311..06d84265de56 100755 --- a/website/scripts/deploy.sh +++ b/website/scripts/deploy.sh @@ -63,13 +63,16 @@ if [ -z "$NO_UPLOAD" ]; then sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/" # The s3cmd guessed mime type for text files is often wrong. This is - # problematic for JS/CSS, so force their mime types to be correct. + # problematic for some assets, so force their mime types to be correct. s3cmd \ --mime-type="application/javascript" \ - modify "s3://hc-sites/$PROJECT/latest/assets/javascripts/*.js" + modify "s3://hc-sites/$PROJECT/latest/**/*.js" s3cmd \ --mime-type="text/css" \ - modify "s3://hc-sites/$PROJECT/latest/assets/stylesheets/*.css" + modify "s3://hc-sites/$PROJECT/latest/**/*.css" + s3cmd \ + --mime-type="image/svg+xml" \ + modify "s3://hc-sites/$PROJECT/latest/**/*.svg" fi # Perform a soft-purge of the surrogate key. From 8380a7b03eec090f4c41c571531ede303ec26880 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 7 Apr 2016 12:15:00 -0500 Subject: [PATCH 020/665] provider/aws: Allow multiple EIPs to associate to single ENI When calling AssociateAddress, the PrivateIpAddress parameter must be used to select which private IP the EIP should associate with, otherwise the EIP always associates with the _first_ private IP. Without this parameter, multiple EIPs couldn't be assigned to a single ENI. Includes covering test and docs update. Fixes #2997 --- builtin/providers/aws/resource_aws_eip.go | 6 ++ .../providers/aws/resource_aws_eip_test.go | 55 ++++++++++++++++++- .../docs/providers/aws/r/eip.html.markdown | 28 +++++++++- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index b147b99caa9d..ee1aec8bc80a 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -61,6 +61,7 @@ func resourceAwsEip() *schema.Resource { "private_ip": &schema.Schema{ Type: schema.TypeString, + Optional: true, Computed: true, }, }, @@ -180,10 +181,15 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error { // more unique ID conditionals if domain == "vpc" { + var privateIpAddress *string + if v := d.Get("private_ip").(string); v != "" { + privateIpAddress = aws.String(v) + } assocOpts = &ec2.AssociateAddressInput{ NetworkInterfaceId: aws.String(networkInterfaceId), InstanceId: aws.String(instanceId), AllocationId: aws.String(d.Id()), + PrivateIpAddress: privateIpAddress, } } diff --git a/builtin/providers/aws/resource_aws_eip_test.go b/builtin/providers/aws/resource_aws_eip_test.go index 56955a8c11f7..ef3e8113bd5a 100644 --- a/builtin/providers/aws/resource_aws_eip_test.go +++ b/builtin/providers/aws/resource_aws_eip_test.go @@ -78,6 +78,29 @@ func TestAccAWSEIP_network_interface(t *testing.T) { }) } +func TestAccAWSEIP_twoEIPsOneNetworkInterface(t *testing.T) { + var one, two ec2.Address + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEIPDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSEIPMultiNetworkInterfaceConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEIPExists("aws_eip.one", &one), + testAccCheckAWSEIPAttributes(&one), + testAccCheckAWSEIPAssociated(&one), + testAccCheckAWSEIPExists("aws_eip.two", &two), + testAccCheckAWSEIPAttributes(&two), + testAccCheckAWSEIPAssociated(&two), + ), + }, + }, + }) +} + func testAccCheckAWSEIPDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).ec2conn @@ -136,7 +159,7 @@ func testAccCheckAWSEIPAttributes(conf *ec2.Address) resource.TestCheckFunc { func testAccCheckAWSEIPAssociated(conf *ec2.Address) resource.TestCheckFunc { return func(s *terraform.State) error { - if *conf.AssociationId == "" { + if conf.AssociationId == nil || *conf.AssociationId == "" { return fmt.Errorf("empty association_id") } @@ -220,6 +243,7 @@ resource "aws_eip" "bar" { instance = "${aws_instance.bar.id}" } ` + const testAccAWSEIPNetworkInterfaceConfig = ` resource "aws_vpc" "bar" { cidr_block = "10.0.0.0/24" @@ -242,3 +266,32 @@ resource "aws_eip" "bar" { network_interface = "${aws_network_interface.bar.id}" } ` + +const testAccAWSEIPMultiNetworkInterfaceConfig = ` +resource "aws_vpc" "bar" { + cidr_block = "10.0.0.0/24" +} +resource "aws_internet_gateway" "bar" { + vpc_id = "${aws_vpc.bar.id}" +} +resource "aws_subnet" "bar" { + vpc_id = "${aws_vpc.bar.id}" + availability_zone = "us-west-2a" + cidr_block = "10.0.0.0/24" +} +resource "aws_network_interface" "bar" { + subnet_id = "${aws_subnet.bar.id}" + private_ips = ["10.0.0.10", "10.0.0.11"] + security_groups = [ "${aws_vpc.bar.default_security_group_id}" ] +} +resource "aws_eip" "one" { + vpc = "true" + network_interface = "${aws_network_interface.bar.id}" + private_ip = "10.0.0.10" +} +resource "aws_eip" "two" { + vpc = "true" + network_interface = "${aws_network_interface.bar.id}" + private_ip = "10.0.0.11" +} +` diff --git a/website/source/docs/providers/aws/r/eip.html.markdown b/website/source/docs/providers/aws/r/eip.html.markdown index a4d01777a01d..63f9ae5c0f9f 100644 --- a/website/source/docs/providers/aws/r/eip.html.markdown +++ b/website/source/docs/providers/aws/r/eip.html.markdown @@ -12,10 +12,31 @@ Provides an Elastic IP resource. ## Example Usage +Single EIP associated with an instance: + ``` resource "aws_eip" "lb" { - instance = "${aws_instance.web.id}" - vpc = true + instance = "${aws_instance.web.id}" + vpc = true +} +``` + +Muliple EIPs associated with a single network interface: + +``` +resource "aws_network_interface" "multi-ip" { + subnet_id = "${aws_subnet.main.id}" + private_ips = ["10.0.0.10", "10.0.0.11"] +} +resource "aws_eip" "one" { + vpc = true + network_interface = "${aws_network_interface.multi-ip.id}" + private_ip = "10.0.0.10" +} +resource "aws_eip" "two" { + vpc = true + network_interface = "${aws_network_interface.multi-ip.id}" + private_ip = "10.0.0.11" } ``` @@ -26,6 +47,9 @@ The following arguments are supported: * `vpc` - (Optional) Boolean if the EIP is in a VPC or not. * `instance` - (Optional) EC2 instance ID. * `network_interface` - (Optional) Network interface ID to associate with. +* `private_ip` - (Optional) The primary or secondary private IP address to + associate with the Elastic IP address. If no private IP address is specified, + the Elastic IP address is associated with the primary private IP address. ~> **NOTE:** You can specify either the `instance` ID or the `network_interface` ID, but not both. Including both will **not** return an error from the AWS API, but will From f1638097e5de367f0f57af49a40c0ff92f6f88b4 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 7 Apr 2016 14:38:52 -0500 Subject: [PATCH 021/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f454b3e8c8e..055a94371f21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ IMPROVEMENTS: * provider/aws: `aws_codecommit_repository` set `default_branch` only if defined [GH-5904] * provider/aws: `aws_redshift_cluster` allows usernames with underscore in it [GH-5935] * provider/aws: normalize json for `aws_cloudwatch_event_rule` [GH-6025] + * provider/aws: Allow multiple EIPs to associate to single ENI [GH-6070] * provider/clc: Override default `account` alias in provider config [GH-5785] * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] * provider/docker: Add support for docker run --user option [GH-5300] From 6bf9f21c398da289151c0e1120b78fd175f8dc85 Mon Sep 17 00:00:00 2001 From: Jan Nabbefeld Date: Tue, 22 Dec 2015 17:45:27 +0100 Subject: [PATCH 022/665] Opsworks Application support --- builtin/providers/aws/provider.go | 1 + .../aws/resource_aws_opsworks_application.go | 603 ++++++++++++++++++ .../resource_aws_opsworks_application_test.go | 221 +++++++ .../aws/r/opsworks_application.html.markdown | 94 +++ website/source/layouts/aws.erb | 4 + 5 files changed, 923 insertions(+) create mode 100644 builtin/providers/aws/resource_aws_opsworks_application.go create mode 100644 builtin/providers/aws/resource_aws_opsworks_application_test.go create mode 100644 website/source/docs/providers/aws/r/opsworks_application.html.markdown diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index 01d55a8992d9..bf1641067797 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -199,6 +199,7 @@ func Provider() terraform.ResourceProvider { "aws_network_acl": resourceAwsNetworkAcl(), "aws_network_acl_rule": resourceAwsNetworkAclRule(), "aws_network_interface": resourceAwsNetworkInterface(), + "aws_opsworks_application": resourceAwsOpsworksApplication(), "aws_opsworks_stack": resourceAwsOpsworksStack(), "aws_opsworks_java_app_layer": resourceAwsOpsworksJavaAppLayer(), "aws_opsworks_haproxy_layer": resourceAwsOpsworksHaproxyLayer(), diff --git a/builtin/providers/aws/resource_aws_opsworks_application.go b/builtin/providers/aws/resource_aws_opsworks_application.go new file mode 100644 index 000000000000..cf63c3b2344e --- /dev/null +++ b/builtin/providers/aws/resource_aws_opsworks_application.go @@ -0,0 +1,603 @@ +package aws + +import ( + "fmt" + "log" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/opsworks" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceAwsOpsworksApplication() *schema.Resource { + return &schema.Resource{ + + Create: resourceAwsOpsworksApplicationCreate, + Read: resourceAwsOpsworksApplicationRead, + Update: resourceAwsOpsworksApplicationUpdate, + Delete: resourceAwsOpsworksApplicationDelete, + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "short_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + // aws-flow-ruby | java | rails | php | nodejs | static | other + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "stack_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + // TODO: the following 4 vals are really part of the Attributes array. We should validate that only ones relevant to the chosen type are set, perhaps. (what is the default type? how do they map?) + "document_root": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + //Default: "public", + }, + "rails_env": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + //Default: "production", + }, + "auto_bundle_on_deploy": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + //Default: true, + }, + "aws_flow_ruby_settings": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "app_source": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + + "url": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "revision": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "ssh_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + // AutoSelectOpsworksMysqlInstance, OpsworksMysqlInstance, or RdsDbInstance. + // anything beside auto select will lead into failure in case the instance doesn't exist + // XXX: validation? + "data_source_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "data_source_database_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "data_source_arn": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "domains": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "environment": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "secure": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + }, + }, + }, + "enable_ssl": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "ssl_configuration": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + //Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate": &schema.Schema{ + Type: schema.TypeString, + Required: true, + StateFunc: func(v interface{}) string { + switch v.(type) { + case string: + return strings.TrimSpace(v.(string)) + default: + return "" + } + }, + }, + "private_key": &schema.Schema{ + Type: schema.TypeString, + Required: true, + StateFunc: func(v interface{}) string { + switch v.(type) { + case string: + return strings.TrimSpace(v.(string)) + default: + return "" + } + }, + }, + "chain": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + StateFunc: func(v interface{}) string { + switch v.(type) { + case string: + return strings.TrimSpace(v.(string)) + default: + return "" + } + }, + }, + }, + }, + }, + }, + } +} + +func resourceAwsOpsworksApplicationValidate(d *schema.ResourceData) error { + appSourceCount := d.Get("app_source.#").(int) + if appSourceCount > 1 { + return fmt.Errorf("Only one app_source is permitted.") + } + + sslCount := d.Get("ssl_configuration.#").(int) + if sslCount > 1 { + return fmt.Errorf("Only one ssl_configuration is permitted.") + } + + if d.Get("type").(string) == opsworks.AppTypeRails { + if _, ok := d.GetOk("rails_env"); !ok { + return fmt.Errorf("Set rails_env must be set if type is set to rails.") + } + } + switch d.Get("type").(string) { + case opsworks.AppTypeStatic: + case opsworks.AppTypeRails: + case opsworks.AppTypePhp: + case opsworks.AppTypeOther: + case opsworks.AppTypeNodejs: + case opsworks.AppTypeJava: + case opsworks.AppTypeAwsFlowRuby: + log.Printf("[DEBUG] type supported") + default: + return fmt.Errorf("opsworks_application.type must be one of %s, %s, %s, %s, %s, %s, %s", + opsworks.AppTypeStatic, + opsworks.AppTypeRails, + opsworks.AppTypePhp, + opsworks.AppTypeOther, + opsworks.AppTypeNodejs, + opsworks.AppTypeJava, + opsworks.AppTypeAwsFlowRuby) + } + + return nil +} + +func resourceAwsOpsworksApplicationRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + req := &opsworks.DescribeAppsInput{ + AppIds: []*string{ + aws.String(d.Id()), + }, + } + + log.Printf("[DEBUG] Reading OpsWorks app: %s", d.Id()) + + resp, err := client.DescribeApps(req) + if err != nil { + if awserr, ok := err.(awserr.Error); ok { + if awserr.Code() == "ResourceNotFoundException" { + log.Printf("[INFO] App not found: %s", d.Id()) + d.SetId("") + return nil + } + } + return err + } + + app := resp.Apps[0] + + d.Set("name", app.Name) + d.Set("stack_id", app.StackId) + d.Set("type", app.Type) + d.Set("description", app.Description) + d.Set("domains", flattenStringList(app.Domains)) + d.Set("enable_ssl", app.EnableSsl) + resourceAwsOpsworksSetApplicationSsl(d, app.SslConfiguration) + resourceAwsOpsworksSetApplicationSource(d, app.AppSource) + resourceAwsOpsworksSetApplicationDataSources(d, app.DataSources) + resourceAwsOpsworksSetApplicationEnvironmentVariable(d, app.Environment) + resourceAwsOpsworksSetApplicationAttributes(d, app.Attributes) + return nil +} + +func resourceAwsOpsworksApplicationCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + err := resourceAwsOpsworksApplicationValidate(d) + if err != nil { + return err + } + + req := &opsworks.CreateAppInput{ + Name: aws.String(d.Get("name").(string)), + Shortname: aws.String(d.Get("short_name").(string)), + StackId: aws.String(d.Get("stack_id").(string)), + Type: aws.String(d.Get("type").(string)), + Description: aws.String(d.Get("description").(string)), + Domains: expandStringList(d.Get("domains").([]interface{})), + EnableSsl: aws.Bool(d.Get("enable_ssl").(bool)), + SslConfiguration: resourceAwsOpsworksApplicationSsl(d), + AppSource: resourceAwsOpsworksApplicationSource(d), + DataSources: resourceAwsOpsworksApplicationDataSources(d), + Environment: resourceAwsOpsworksApplicationEnvironmentVariable(d), + Attributes: resourceAwsOpsworksApplicationAttributes(d), + } + + var resp *opsworks.CreateAppOutput + err = resource.Retry(2*time.Minute, func() *resource.RetryError { + var cerr error + resp, cerr = client.CreateApp(req) + if cerr != nil { + log.Printf("[INFO] client error") + if opserr, ok := cerr.(awserr.Error); ok { + // XXX: handle errors + log.Printf("[ERROR] OpsWorks error: %s message: %s", opserr.Code(), opserr.Message()) + return resource.RetryableError(cerr) + } + return resource.NonRetryableError(cerr) + } + return nil + }) + + if err != nil { + return err + } + + appID := *resp.AppId + d.SetId(appID) + d.Set("id", appID) + + return resourceAwsOpsworksApplicationRead(d, meta) +} + +func resourceAwsOpsworksApplicationUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + req := &opsworks.UpdateAppInput{ + AppId: aws.String(d.Id()), + Name: aws.String(d.Get("name").(string)), + Type: aws.String(d.Get("type").(string)), + Description: aws.String(d.Get("description").(string)), + Domains: expandStringList(d.Get("domains").([]interface{})), + EnableSsl: aws.Bool(d.Get("enable_ssl").(bool)), + SslConfiguration: resourceAwsOpsworksApplicationSsl(d), + AppSource: resourceAwsOpsworksApplicationSource(d), + DataSources: resourceAwsOpsworksApplicationDataSources(d), + Environment: resourceAwsOpsworksApplicationEnvironmentVariable(d), + Attributes: resourceAwsOpsworksApplicationAttributes(d), + } + + log.Printf("[DEBUG] Updating OpsWorks layer: %s", d.Id()) + + var resp *opsworks.UpdateAppOutput + err := resource.Retry(2*time.Minute, func() *resource.RetryError { + var cerr error + resp, cerr = client.UpdateApp(req) + if cerr != nil { + log.Printf("[INFO] client error") + if opserr, ok := cerr.(awserr.Error); ok { + // XXX: handle errors + log.Printf("[ERROR] OpsWorks error: %s message: %s", opserr.Code(), opserr.Message()) + return resource.NonRetryableError(cerr) + } + return resource.RetryableError(cerr) + } + return nil + }) + + if err != nil { + return err + } + return resourceAwsOpsworksApplicationRead(d, meta) +} + +func resourceAwsOpsworksApplicationDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*AWSClient).opsworksconn + + req := &opsworks.DeleteAppInput{ + AppId: aws.String(d.Id()), + } + + log.Printf("[DEBUG] Deleting OpsWorks application: %s", d.Id()) + + _, err := client.DeleteApp(req) + return err +} + +func resourceAwsOpsworksSetApplicationEnvironmentVariable(d *schema.ResourceData, v []*opsworks.EnvironmentVariable) { + log.Printf("[DEBUG] envs: %s %d", v, len(v)) + if len(v) == 0 { + d.Set("environment", nil) + return + } + newValue := make([]*map[string]interface{}, len(v)) + + for i := 0; i < len(v); i++ { + config := v[i] + data := make(map[string]interface{}) + newValue[i] = &data + + if config.Key != nil { + data["key"] = *config.Key + } + if config.Value != nil { + data["value"] = *config.Value + } + if config.Secure != nil { + + if bool(*config.Secure) { + data["secure"] = &opsworksTrueString + } else { + data["secure"] = &opsworksFalseString + } + } + log.Printf("[DEBUG] v: %s", data) + } + + d.Set("environment", newValue) +} + +func resourceAwsOpsworksApplicationEnvironmentVariable(d *schema.ResourceData) []*opsworks.EnvironmentVariable { + environmentVariables := d.Get("environment").(*schema.Set).List() + result := make([]*opsworks.EnvironmentVariable, len(environmentVariables)) + + for i := 0; i < len(environmentVariables); i++ { + env := environmentVariables[i].(map[string]interface{}) + + result[i] = &opsworks.EnvironmentVariable{ + Key: aws.String(env["key"].(string)), + Value: aws.String(env["value"].(string)), + Secure: aws.Bool(env["secure"].(bool)), + } + } + return result +} + +func resourceAwsOpsworksApplicationSource(d *schema.ResourceData) *opsworks.Source { + count := d.Get("app_source.#").(int) + if count == 0 { + return nil + } + + return &opsworks.Source{ + Type: aws.String(d.Get("app_source.0.type").(string)), + Url: aws.String(d.Get("app_source.0.url").(string)), + Username: aws.String(d.Get("app_source.0.username").(string)), + Password: aws.String(d.Get("app_source.0.password").(string)), + Revision: aws.String(d.Get("app_source.0.revision").(string)), + SshKey: aws.String(d.Get("app_source.0.ssh_key").(string)), + } +} + +func resourceAwsOpsworksSetApplicationSource(d *schema.ResourceData, v *opsworks.Source) { + nv := make([]interface{}, 0, 1) + if v != nil { + m := make(map[string]interface{}) + if v.Type != nil { + m["type"] = *v.Type + } + if v.Url != nil { + m["url"] = *v.Url + } + if v.Username != nil { + m["username"] = *v.Username + } + if v.Password != nil { + m["password"] = *v.Password + } + if v.Revision != nil { + m["revision"] = *v.Revision + } + if v.SshKey != nil { + m["ssh_key"] = *v.SshKey + } + nv = append(nv, m) + } + + err := d.Set("app_source", nv) + if err != nil { + // should never happen + panic(err) + } +} + +func resourceAwsOpsworksApplicationDataSources(d *schema.ResourceData) []*opsworks.DataSource { + arn := d.Get("data_source_arn").(string) + databaseName := d.Get("data_source_database_name").(string) + databaseType := d.Get("data_source_type").(string) + + result := make([]*opsworks.DataSource, 1) + + if len(arn) > 0 || len(databaseName) > 0 || len(databaseType) > 0 { + result[0] = &opsworks.DataSource{ + Arn: aws.String(arn), + DatabaseName: aws.String(databaseName), + Type: aws.String(databaseType), + } + } + return result +} + +func resourceAwsOpsworksSetApplicationDataSources(d *schema.ResourceData, v []*opsworks.DataSource) { + d.Set("data_source_arn", nil) + d.Set("data_source_database_name", nil) + d.Set("data_source_type", nil) + + if len(v) == 0 { + return + } + + d.Set("data_source_arn", v[0].Arn) + d.Set("data_source_database_name", v[0].DatabaseName) + d.Set("data_source_type", v[0].Type) +} + +func resourceAwsOpsworksApplicationSsl(d *schema.ResourceData) *opsworks.SslConfiguration { + count := d.Get("ssl_configuration.#").(int) + if count == 0 { + return nil + } + + return &opsworks.SslConfiguration{ + PrivateKey: aws.String(d.Get("ssl_configuration.0.private_key").(string)), + Certificate: aws.String(d.Get("ssl_configuration.0.certificate").(string)), + Chain: aws.String(d.Get("ssl_configuration.0.chain").(string)), + } +} + +func resourceAwsOpsworksSetApplicationSsl(d *schema.ResourceData, v *opsworks.SslConfiguration) { + nv := make([]interface{}, 0, 1) + set := false + if v != nil { + m := make(map[string]interface{}) + if v.PrivateKey != nil { + m["private_key"] = *v.PrivateKey + set = true + } + if v.Certificate != nil { + m["certificate"] = *v.Certificate + set = true + } + if v.Chain != nil { + m["chain"] = *v.Chain + set = true + } + if set { + nv = append(nv, m) + } + } + + err := d.Set("ssl_configuration", nv) + if err != nil { + // should never happen + panic(err) + } +} + +func resourceAwsOpsworksApplicationAttributes(d *schema.ResourceData) map[string]*string { + if d.Get("type") != opsworks.AppTypeRails { + return nil + } + attributes := make(map[string]*string) + + if val := d.Get("document_root").(string); len(val) > 0 { + attributes[opsworks.AppAttributesKeysDocumentRoot] = aws.String(val) + } + if val := d.Get("aws_flow_ruby_settings").(string); len(val) > 0 { + attributes[opsworks.AppAttributesKeysAwsFlowRubySettings] = aws.String(val) + } + if val := d.Get("rails_env").(string); len(val) > 0 { + attributes[opsworks.AppAttributesKeysRailsEnv] = aws.String(val) + } + if val := d.Get("auto_bundle_on_deploy").(string); len(val) > 0 { + if val == "1" { + val = "true" + } else if val == "0" { + val = "false" + } + attributes[opsworks.AppAttributesKeysAutoBundleOnDeploy] = aws.String(val) + } + + return attributes +} + +func resourceAwsOpsworksSetApplicationAttributes(d *schema.ResourceData, v map[string]*string) { + d.Set("document_root", nil) + d.Set("rails_env", nil) + d.Set("aws_flow_ruby_settings", nil) + d.Set("auto_bundle_on_deploy", nil) + + if d.Get("type") != opsworks.AppTypeRails { + return + } + if val, ok := v[opsworks.AppAttributesKeysDocumentRoot]; ok { + d.Set("document_root", val) + } + if val, ok := v[opsworks.AppAttributesKeysAwsFlowRubySettings]; ok { + d.Set("aws_flow_ruby_settings", val) + } + if val, ok := v[opsworks.AppAttributesKeysRailsEnv]; ok { + d.Set("rails_env", val) + } + if val, ok := v[opsworks.AppAttributesKeysAutoBundleOnDeploy]; ok { + d.Set("auto_bundle_on_deploy", val) + } +} diff --git a/builtin/providers/aws/resource_aws_opsworks_application_test.go b/builtin/providers/aws/resource_aws_opsworks_application_test.go new file mode 100644 index 000000000000..7f202be3721f --- /dev/null +++ b/builtin/providers/aws/resource_aws_opsworks_application_test.go @@ -0,0 +1,221 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/opsworks" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAWSOpsworksApplication(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsOpsworksApplicationDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAwsOpsworksApplicationCreate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "name", "tf-ops-acc-application", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "type", "other", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "enable_ssl", "false", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "ssl_configuration", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "domains", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.key", "key1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.value", "value1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.secret", "", + ), + ), + }, + resource.TestStep{ + Config: testAccAwsOpsworksApplicationUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "name", "tf-ops-acc-application", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "type", "rails", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "enable_ssl", "true", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "ssl_configuration.0.certificate", "-----BEGIN CERTIFICATE-----\nMIIBkDCB+gIJALoScFD0sJq3MA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNVBAYTAkRF\nMB4XDTE1MTIxOTIwMzU1MVoXDTE2MDExODIwMzU1MVowDTELMAkGA1UEBhMCREUw\ngZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKKQKbTTH/Julz16xY7ArYlzJYCP\nedTCx1bopuryCx/+d1gC94MtRdlPSpQl8mfc9iBdtXbJppp73Qh/DzLzO9Ns25xZ\n+kUQMhbIyLsaCBzuEGLgAaVdGpNvRBw++UoYtd0U7QczFAreTGLH8n8+FIzuI5Mc\n+MJ1TKbbt5gFfRSzAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEALARo96wCDmaHKCaX\nS0IGLGnZCfiIUfCmBxOXBSJxDBwter95QHR0dMGxYIujee5n4vvavpVsqZnfMC3I\nOZWPlwiUJbNIpK+04Bg2vd5m/NMMrvi75RfmyeMtSfq/NrIX2Q3+nyWI7DLq7yZI\nV/YEvOqdAiy5NEWBztHx8HvB9G4=\n-----END CERTIFICATE-----", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "ssl_configuration.0.private_key", "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQCikCm00x/ybpc9esWOwK2JcyWAj3nUwsdW6Kbq8gsf/ndYAveD\nLUXZT0qUJfJn3PYgXbV2yaaae90Ifw8y8zvTbNucWfpFEDIWyMi7Gggc7hBi4AGl\nXRqTb0QcPvlKGLXdFO0HMxQK3kxix/J/PhSM7iOTHPjCdUym27eYBX0UswIDAQAB\nAoGBAIYcrvuqDboguI8U4TUjCkfSAgds1pLLWk79wu8jXkA329d1IyNKT0y3WIye\nPbyoEzmidZmZROQ/+ZsPz8c12Y0DrX73WSVzKNyJeP7XMk9HSzA1D9RX0U0S+5Kh\nFAMc2NEVVFIfQtVtoVmHdKDpnRYtOCHLW9rRpvqOOjd4mYk5AkEAzeiFr1mtlnsa\n67shMxzDaOTAFMchRz6G7aSovvCztxcB63ulFI/w9OTUMdTQ7ff7pet+lVihLc2W\nefIL0HvsjQJBAMocNTKaR/TnsV5GSk2kPAdR+zFP5sQy8sfMy0lEXTylc7zN4ajX\nMeHVoxp+GZgpfDcZ3ya808H1umyXh+xA1j8CQE9x9ZKQYT98RAjL7KVR5btk9w+N\nPTPF1j1+mHUDXfO4ds8qp6jlWKzEVXLcj7ghRADiebaZuaZ4eiSW1SQdjEkCQQC4\nwDhQ3X9RfEpCp3ZcqvjEqEg6t5N3XitYQPjDLN8eBRBbUsgpEy3iBuxl10eGNMX7\niIbYXlwkPYAArDPv3wT5AkAwp4vym+YKmDqh6gseKfRDuJqRiW9yD5A8VGr/w88k\n5rkuduVGP7tK3uIp00Its3aEyKF8mLGWYszVGeeLxAMH\n-----END RSA PRIVATE KEY-----", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "domains.0", "example.com", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "domains.1", "sub.example.com", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.password", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.revision", "master", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.ssh_key", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.type", "git", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.url", "https://github.com/aws/example.git", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "app_source.0.username", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.2107898637.key", "key2", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.2107898637.value", "value2", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.2107898637.secure", "true", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.key", "key1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.value", "value1", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "environment.3077298702.secret", "", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "document_root", "root", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "auto_bundle_on_deploy", "true", + ), + resource.TestCheckResourceAttr( + "aws_opsworks_application.tf-acc-app", "rails_env", "staging", + ), + ), + }, + }, + }) +} + +func testAccCheckAwsOpsworksApplicationDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*AWSClient).opsworksconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_opsworks_application" { + continue + } + + req := &opsworks.DescribeAppsInput{ + AppIds: []*string{ + aws.String(rs.Primary.ID), + }, + } + + resp, err := client.DescribeApps(req) + if err == nil { + if len(resp.Apps) > 0 { + return fmt.Errorf("OpsWorks App still exist.") + } + } + + if awserr, ok := err.(awserr.Error); ok { + if awserr.Code() != "ResourceNotFoundException" { + return err + } + } + } + + return nil +} + +var testAccAwsOpsworksApplicationCreate = testAccAwsOpsworksStackConfigNoVpcCreate("") + ` +resource "aws_opsworks_application" "tf-acc-app" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + name = "tf-ops-acc-application" + type = "other" + enable_ssl = false + app_source ={ + type = "other" + } + environment = { key = "key1" value = "value1" secure = false} +} +` + +var testAccAwsOpsworksApplicationUpdate = testAccAwsOpsworksStackConfigNoVpcCreate("") + ` +resource "aws_opsworks_application" "tf-acc-app" { + stack_id = "${aws_opsworks_stack.tf-acc.id}" + name = "tf-ops-acc-application" + type = "rails" + domains = ["example.com", "sub.example.com"] + enable_ssl = true + ssl_configuration = { + private_key = <aws_opsworks_static_web_layer + > + aws_opsworks_application + + From b9417819c9742911b5adb652e338434188a2382a Mon Sep 17 00:00:00 2001 From: Justin Clayton Date: Thu, 7 Apr 2016 15:09:59 -0700 Subject: [PATCH 023/665] Update compute_instance_v2.html.markdown --- .../providers/openstack/r/compute_instance_v2.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown b/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown index ac855aa305f0..02886c59f863 100644 --- a/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown +++ b/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown @@ -118,10 +118,10 @@ The `network` block supports: The `block_device` block supports: -* `uuid` - (Required) The UUID of the image, volume, or snapshot. +* `uuid` - (Required unless `source_type` is set to `"blank"` ) The UUID of the image, volume, or snapshot. * `source_type` - (Required) The source type of the device. Must be one of - "image", "volume", or "snapshot". + "blank", "image", "volume", or "snapshot". * `volume_size` - The size of the volume to create (in gigabytes). Required in the following combinations: source=image and destination=volume, From f3c4ab1efadb38086c58fa9b488306c4ade4ec60 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Thu, 7 Apr 2016 20:38:24 -0600 Subject: [PATCH 024/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 055a94371f21..60b8c695cbc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ BUG FIXES: * provider/aws: Show human-readable error message when failing to read an EBS volume [GH-6038] * provider/azurerm: Fix detection of `azurerm_storage_account` resources removed manually [GH-5878] * provider/docker: Docker Image will be deleted on destroy [GH-5801] + * provider/openstack: Fix resizing when Flavor Name changes [GH-6020] ## 0.6.14 (March 21, 2016) From a152089e7c9657524efe7e71c8d32804dec8b74a Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Thu, 7 Apr 2016 20:46:14 -0600 Subject: [PATCH 025/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b8c695cbc4..93dcf7d07f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ BUG FIXES: * provider/azurerm: Fix detection of `azurerm_storage_account` resources removed manually [GH-5878] * provider/docker: Docker Image will be deleted on destroy [GH-5801] * provider/openstack: Fix resizing when Flavor Name changes [GH-6020] + * provider/openstack: Fix Disabling DHCP on Subnets [GH-6052] ## 0.6.14 (March 21, 2016) From e9f627ba926489286ee242616d1c4f40f4a7f0eb Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Fri, 8 Apr 2016 02:51:36 +0000 Subject: [PATCH 026/665] vendor: Updating gophercloud for openstack --- Godeps/Godeps.json | 144 +++++++++--------- .../rackspace/gophercloud/openstack/client.go | 12 +- .../v2/extensions/secgroups/fixtures.go | 2 + .../v2/extensions/layer3/routers/requests.go | 63 +++++--- .../openstack/networking/v2/subnets/errors.go | 7 +- .../networking/v2/subnets/requests.go | 16 ++ 6 files changed, 143 insertions(+), 101 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f342abece443..82fcb75c02e1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -970,183 +970,183 @@ }, { "ImportPath": "github.com/rackspace/gophercloud", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/schedulerhints", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/servergroups", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/flavors", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/images", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/servers", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/networks", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/ports", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/subnets", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/openstack/utils", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/pagination", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/testhelper", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/rackspace/gophercloud/testhelper/client", - "Comment": "v1.0.0-831-gf3d0534", - "Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" + "Comment": "v1.0.0-868-ga09b5b4", + "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0" }, { "ImportPath": "github.com/satori/go.uuid", diff --git a/vendor/github.com/rackspace/gophercloud/openstack/client.go b/vendor/github.com/rackspace/gophercloud/openstack/client.go index baa4cb51c2f6..951f4ed40e70 100644 --- a/vendor/github.com/rackspace/gophercloud/openstack/client.go +++ b/vendor/github.com/rackspace/gophercloud/openstack/client.go @@ -134,13 +134,17 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc v3Client.Endpoint = endpoint } + // copy the auth options to a local variable that we can change. `options` + // needs to stay as-is for reauth purposes + v3Options := options + var scope *tokens3.Scope if options.TenantID != "" { scope = &tokens3.Scope{ ProjectID: options.TenantID, } - options.TenantID = "" - options.TenantName = "" + v3Options.TenantID = "" + v3Options.TenantName = "" } else { if options.TenantName != "" { scope = &tokens3.Scope{ @@ -148,11 +152,11 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc DomainID: options.DomainID, DomainName: options.DomainName, } - options.TenantName = "" + v3Options.TenantName = "" } } - result := tokens3.Create(v3Client, options, scope) + result := tokens3.Create(v3Client, v3Options, scope) token, err := result.ExtractToken() if err != nil { diff --git a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go index 28b1c0644972..d58d908943f5 100644 --- a/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go +++ b/vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups/fixtures.go @@ -1,3 +1,5 @@ +// +build fixtures + package secgroups import ( diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go index 1ffc1369b47c..5fde23653343 100644 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go +++ b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go @@ -42,6 +42,14 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { }) } +// CreateOptsBuilder is the interface options structs have to satisfy in order +// to be used in the main Create operation in this package. Since many +// extensions decorate or modify the common logic, it is useful for them to +// satisfy a basic interface in order for them to be used. +type CreateOptsBuilder interface { + ToRouterCreateMap() (map[string]interface{}, error) +} + // CreateOpts contains all the values needed to create a new router. There are // no required values. type CreateOpts struct { @@ -52,6 +60,33 @@ type CreateOpts struct { GatewayInfo *GatewayInfo } +// ToRouterCreateMap casts a CreateOpts struct to a map. +func (opts CreateOpts) ToRouterCreateMap() (map[string]interface{}, error) { + r := make(map[string]interface{}) + + if gophercloud.MaybeString(opts.Name) != nil { + r["name"] = opts.Name + } + + if opts.AdminStateUp != nil { + r["admin_state_up"] = opts.AdminStateUp + } + + if opts.Distributed != nil { + r["distributed"] = opts.Distributed + } + + if gophercloud.MaybeString(opts.TenantID) != nil { + r["tenant_id"] = opts.TenantID + } + + if opts.GatewayInfo != nil { + r["external_gateway_info"] = opts.GatewayInfo + } + + return map[string]interface{}{"router": r}, nil +} + // Create accepts a CreateOpts struct and uses the values to create a new // logical router. When it is created, the router does not have an internal // interface - it is not associated to any subnet. @@ -60,31 +95,15 @@ type CreateOpts struct { // GatewayInfo struct. The external gateway for the router must be plugged into // an external network (it is external if its `router:external' field is set to // true). -func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { - type router struct { - Name *string `json:"name,omitempty"` - AdminStateUp *bool `json:"admin_state_up,omitempty"` - Distributed *bool `json:"distributed,omitempty"` - TenantID *string `json:"tenant_id,omitempty"` - GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"` - } - - type request struct { - Router router `json:"router"` - } - - reqBody := request{Router: router{ - Name: gophercloud.MaybeString(opts.Name), - AdminStateUp: opts.AdminStateUp, - Distributed: opts.Distributed, - TenantID: gophercloud.MaybeString(opts.TenantID), - }} +func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult { + var res CreateResult - if opts.GatewayInfo != nil { - reqBody.Router.GatewayInfo = opts.GatewayInfo + reqBody, err := opts.ToRouterCreateMap() + if err != nil { + res.Err = err + return res } - var res CreateResult _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) return res } diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go index 0db0a6e60477..d2f7b46e3c89 100644 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go +++ b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/errors.go @@ -7,7 +7,8 @@ func err(str string) error { } var ( - errNetworkIDRequired = err("A network ID is required") - errCIDRRequired = err("A valid CIDR is required") - errInvalidIPType = err("An IP type must either be 4 or 6") + errNetworkIDRequired = err("A network ID is required") + errCIDRRequired = err("A valid CIDR is required") + errInvalidIPType = err("An IP type must either be 4 or 6") + errInvalidGatewayConfig = err("Both disabling the gateway and specifying a gateway is not allowed") ) diff --git a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go index 6cde048ed04c..8fa1e6dbe221 100644 --- a/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go +++ b/vendor/github.com/rackspace/gophercloud/openstack/networking/v2/subnets/requests.go @@ -108,6 +108,7 @@ type CreateOpts struct { TenantID string AllocationPools []AllocationPool GatewayIP string + NoGateway bool IPVersion int EnableDHCP *bool DNSNameservers []string @@ -128,6 +129,11 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { return nil, errInvalidIPType } + // Both GatewayIP and NoGateway should not be set + if opts.GatewayIP != "" && opts.NoGateway { + return nil, errInvalidGatewayConfig + } + s["network_id"] = opts.NetworkID s["cidr"] = opts.CIDR @@ -139,6 +145,8 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) { } if opts.GatewayIP != "" { s["gateway_ip"] = opts.GatewayIP + } else if opts.NoGateway { + s["gateway_ip"] = nil } if opts.TenantID != "" { s["tenant_id"] = opts.TenantID @@ -184,6 +192,7 @@ type UpdateOptsBuilder interface { type UpdateOpts struct { Name string GatewayIP string + NoGateway bool DNSNameservers []string HostRoutes []HostRoute EnableDHCP *bool @@ -193,6 +202,11 @@ type UpdateOpts struct { func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { s := make(map[string]interface{}) + // Both GatewayIP and NoGateway should not be set + if opts.GatewayIP != "" && opts.NoGateway { + return nil, errInvalidGatewayConfig + } + if opts.EnableDHCP != nil { s["enable_dhcp"] = &opts.EnableDHCP } @@ -201,6 +215,8 @@ func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { } if opts.GatewayIP != "" { s["gateway_ip"] = opts.GatewayIP + } else if opts.NoGateway { + s["gateway_ip"] = nil } if opts.DNSNameservers != nil { s["dns_nameservers"] = opts.DNSNameservers From 28f98c370134cf46ed3516e5f266a8041e259ba3 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Fri, 8 Apr 2016 03:12:49 +0000 Subject: [PATCH 027/665] provider/openstack: Allow subnets with no gateway This commit adds a no_gateway attribute. When set, the subnet will not have a gateway. This is different than not specifying a gateway_ip since that will cause a default gateway of .1 to be used. This behavior mirrors the OpenStack Neutron command-line tool. Fixes #6031 --- ...resource_openstack_networking_subnet_v2.go | 23 +++++++ ...rce_openstack_networking_subnet_v2_test.go | 61 +++++++++++++++++++ .../r/networking_subnet_v2.html.markdown | 7 ++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go index cef09641b791..c3ca944f4f45 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go @@ -70,6 +70,11 @@ func resourceNetworkingSubnetV2() *schema.Resource { ForceNew: false, Computed: true, }, + "no_gateway": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + ForceNew: false, + }, "ip_version": &schema.Schema{ Type: schema.TypeInt, Optional: true, @@ -117,6 +122,12 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error creating OpenStack networking client: %s", err) } + if _, ok := d.GetOk("gateway_ip"); ok { + if _, ok2 := d.GetOk("no_gateway"); ok2 { + return fmt.Errorf("Both gateway_ip and no_gateway cannot be set.") + } + } + enableDHCP := d.Get("enable_dhcp").(bool) createOpts := subnets.CreateOpts{ @@ -126,6 +137,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) TenantID: d.Get("tenant_id").(string), AllocationPools: resourceSubnetAllocationPoolsV2(d), GatewayIP: d.Get("gateway_ip").(string), + NoGateway: d.Get("no_gateway").(bool), IPVersion: d.Get("ip_version").(int), DNSNameservers: resourceSubnetDNSNameserversV2(d), HostRoutes: resourceSubnetHostRoutesV2(d), @@ -190,6 +202,13 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error creating OpenStack networking client: %s", err) } + // Check if both gateway_ip and no_gateway are set + if _, ok := d.GetOk("gateway_ip"); ok { + if _, ok2 := d.GetOk("no_gateway"); ok2 { + return fmt.Errorf("Both gateway_ip and no_gateway cannot be set.") + } + } + var updateOpts subnets.UpdateOpts if d.HasChange("name") { @@ -200,6 +219,10 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) updateOpts.GatewayIP = d.Get("gateway_ip").(string) } + if d.HasChange("no_gateway") { + updateOpts.NoGateway = d.Get("no_gateway").(bool) + } + if d.HasChange("dns_nameservers") { updateOpts.DNSNameservers = resourceSubnetDNSNameserversV2(d) } diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go index 1931d80ebc57..769a12c5f820 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go @@ -55,6 +55,44 @@ func TestAccNetworkingV2Subnet_enableDHCP(t *testing.T) { }) } +func TestAccNetworkingV2Subnet_noGateway(t *testing.T) { + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SubnetDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Subnet_noGateway, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet), + resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", ""), + ), + }, + }, + }) +} + +func TestAccNetworkingV2Subnet_impliedGateway(t *testing.T) { + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SubnetDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Subnet_impliedGateway, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet), + resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2SubnetDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -145,3 +183,26 @@ var testAccNetworkingV2Subnet_enableDHCP = fmt.Sprintf(` gateway_ip = "192.168.199.1" enable_dhcp = true }`) + +var testAccNetworkingV2Subnet_noGateway = fmt.Sprintf(` + resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" + } + resource "openstack_networking_subnet_v2" "subnet_1" { + name = "tf-test-subnet" + network_id = "${openstack_networking_network_v2.network_1.id}" + cidr = "192.168.199.0/24" + no_gateway = true + }`) + +var testAccNetworkingV2Subnet_impliedGateway = fmt.Sprintf(` + resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" + } + resource "openstack_networking_subnet_v2" "subnet_1" { + name = "tf-test-subnet" + network_id = "${openstack_networking_network_v2.network_1.id}" + cidr = "192.168.199.0/24" + }`) diff --git a/website/source/docs/providers/openstack/r/networking_subnet_v2.html.markdown b/website/source/docs/providers/openstack/r/networking_subnet_v2.html.markdown index 3003cb2c455b..a735454a1242 100644 --- a/website/source/docs/providers/openstack/r/networking_subnet_v2.html.markdown +++ b/website/source/docs/providers/openstack/r/networking_subnet_v2.html.markdown @@ -53,7 +53,12 @@ The following arguments are supported: documented below. Changing this creates a new subnet. * `gateway_ip` - (Optional) Default gateway used by devices in this subnet. - Changing this updates the gateway IP of the existing subnet. + Leaving this blank and not setting `no_gateway` will cause a default + gateway of `.1` to be used. Changing this updates the gateway IP of the + existing subnet. + +* `no_gateway` - (Optional) Do not set a gateway IP on this subnet. Changing + this removes or adds a default gateway IP of the existing subnet. * `enable_dhcp` - (Optional) The administrative state of the network. Acceptable values are "true" and "false". Changing this value enables or From 1d2a8a68e1918200d08083b3f25714632ff2cdc9 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Thu, 7 Apr 2016 21:21:27 -0600 Subject: [PATCH 028/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93dcf7d07f0f..28da64830d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ IMPROVEMENTS: * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] * provider/docker: Add support for docker run --user option [GH-5300] * provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials [GH-6007] + * provider/openstack: Allow subnets with no gateway [GH-6060] BUG FIXES: From 2d3a0c9c64938545f67d99126dbeb87e83ffd3b1 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Fri, 8 Apr 2016 15:50:50 +0200 Subject: [PATCH 029/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28da64830d7d..9f218ea36c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ IMPROVEMENTS: * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] * provider/docker: Add support for docker run --user option [GH-5300] * provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials [GH-6007] + * provider/cloudstack: Deprecate `ipaddress` in favour of `ip_address` in all resources [GH-6010] * provider/openstack: Allow subnets with no gateway [GH-6060] BUG FIXES: From 786cc45d5f46def5e580c5935c987366e752af52 Mon Sep 17 00:00:00 2001 From: "Michael H. Oshita" Date: Fri, 8 Apr 2016 23:54:24 +0900 Subject: [PATCH 030/665] Update cloudwatch_metric_alarm.html.markdown (#6085) On creating CloudWatch metric alarms, I need to get the HealthCheckId dimension. Reference would be useful. ``` dimensions { "HealthCheckId" = "${aws_route53_health_check.foo.id}" } ``` --- .../providers/aws/r/cloudwatch_metric_alarm.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown b/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown index bcd4bc69b601..9b65c76a088d 100644 --- a/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown +++ b/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown @@ -77,3 +77,10 @@ The following arguments are supported: * `insufficient_data_actions` - (Optional) The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Number (ARN). * `ok_actions` - (Optional) The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN). * `unit` - (Optional) The unit for the alarm's associated metric. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the health check + From 576e56025c420da478813285d73f9a97c2dd4bdf Mon Sep 17 00:00:00 2001 From: Justin Clark Date: Fri, 8 Apr 2016 08:01:43 -0700 Subject: [PATCH 031/665] Add undocumented custom_json argument to opsworks_stack doc (#6074) --- .../docs/providers/aws/r/opsworks_stack.html.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown index d664ca1a9520..84ee99ad4c0e 100644 --- a/website/source/docs/providers/aws/r/opsworks_stack.html.markdown +++ b/website/source/docs/providers/aws/r/opsworks_stack.html.markdown @@ -18,6 +18,13 @@ resource "aws_opsworks_stack" "main" { region = "us-west-1" service_role_arn = "${aws_iam_role.opsworks.arn}" default_instance_profile_arn = "${aws_iam_instance_profile.opsworks.arn}" + custom_json = < Date: Fri, 8 Apr 2016 10:57:44 -0500 Subject: [PATCH 032/665] provider/triton: Change triton docs to reflect key_material not key_path (#6090) --- website/source/docs/providers/triton/index.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/source/docs/providers/triton/index.html.markdown b/website/source/docs/providers/triton/index.html.markdown index d24fe50bf43b..8434e6ec2612 100644 --- a/website/source/docs/providers/triton/index.html.markdown +++ b/website/source/docs/providers/triton/index.html.markdown @@ -16,9 +16,9 @@ Use the navigation to the left to read about the available resources. ``` provider "triton" { - account = "AccountName" - key_path = "~/.ssh/id_rsa" - key_id = "25:d4:a9:fe:ef:e6:c0:bf:b4:4b:4b:d4:a8:8f:01:0f" + account = "AccountName" + key_material = "~/.ssh/id_rsa" + key_id = "25:d4:a9:fe:ef:e6:c0:bf:b4:4b:4b:d4:a8:8f:01:0f" # If using a private installation of Triton, specify the URL url = "https://us-west-1.api.joyentcloud.com" @@ -30,6 +30,6 @@ provider "triton" { The following arguments are supported in the `provider` block: * `account` - (Required) This is the name of the Triton account. It can also be provided via the `SDC_ACCOUNT` environment variable. -* `key_path` - (Required) This is the path to the private key of an SSH key associated with the Triton account to be used. +* `key_material` - (Required) This is the path to the private key of an SSH key associated with the Triton account to be used. * `key_id` - (Required) This is the fingerprint of the public key matching the key specified in `key_path`. It can be obtained via the command `ssh-keygen -l -E md5 -f /path/to/key` * `url` - (Optional) This is the URL to the Triton API endpoint. It is required if using a private installation of Triton. The default is to use the Joyent public cloud. From 0fdf91661d121d56314ad1e899b17729b2d0ee05 Mon Sep 17 00:00:00 2001 From: Hector Rivas Gandara Date: Fri, 8 Apr 2016 19:55:50 +0100 Subject: [PATCH 033/665] provider/aws: normalize json policy for sns topic policy attribute (#6089) * provider/aws: test empty plan with sns_topic policy with random order If we setup a sns_topic policy with a policy with a different order to the one set by the AWS API, terraform plan will be not empty between runs. * provider/aws: normalize json policy for sns topic For the policy attribute of the resource aws_sns_topic, AWS returns the policy in JSON format with the fields in a different order. If we store and compare the values without normalizing, terraform will unnecesary trigger and update of the resource. To avoid that, we must add a normalization function in the StateFunc of the policy attribute and also when we read the attribute from AWS. --- builtin/providers/aws/resource_aws_sns_topic.go | 13 ++++++++++--- .../providers/aws/resource_aws_sns_topic_test.go | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_sns_topic.go b/builtin/providers/aws/resource_aws_sns_topic.go index 6a8e62fa7e33..4174e8732c94 100644 --- a/builtin/providers/aws/resource_aws_sns_topic.go +++ b/builtin/providers/aws/resource_aws_sns_topic.go @@ -56,7 +56,9 @@ func resourceAwsSnsTopic() *schema.Resource { log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic") return "" } - return buffer.String() + value := normalizeJson(buffer.String()) + log.Printf("[DEBUG] topic policy before save: %s", value) + return value }, }, "delivery_policy": &schema.Schema{ @@ -183,9 +185,14 @@ func resourceAwsSnsTopicRead(d *schema.ResourceData, meta interface{}) error { // Some of the fetched attributes are stateful properties such as // the number of subscriptions, the owner, etc. skip those if resource.Schema[iKey] != nil { - value := *attrmap[oKey] + var value string + if iKey == "policy" { + value = normalizeJson(*attrmap[oKey]) + } else { + value = *attrmap[oKey] + } log.Printf("[DEBUG] Reading %s => %s -> %s", iKey, oKey, value) - d.Set(iKey, *attrmap[oKey]) + d.Set(iKey, value) } } } diff --git a/builtin/providers/aws/resource_aws_sns_topic_test.go b/builtin/providers/aws/resource_aws_sns_topic_test.go index 76510c76ee6c..2852c36fb2c3 100644 --- a/builtin/providers/aws/resource_aws_sns_topic_test.go +++ b/builtin/providers/aws/resource_aws_sns_topic_test.go @@ -128,8 +128,6 @@ resource "aws_sns_topic" "test_topic" { name = "example" policy = < Date: Fri, 8 Apr 2016 13:57:35 -0500 Subject: [PATCH 034/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f218ea36c84..da7baee357f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ IMPROVEMENTS: * provider/aws: `aws_codecommit_repository` set `default_branch` only if defined [GH-5904] * provider/aws: `aws_redshift_cluster` allows usernames with underscore in it [GH-5935] * provider/aws: normalize json for `aws_cloudwatch_event_rule` [GH-6025] + * provider/aws: normalise json for `aws_sns_topic` [GH-6089] * provider/aws: Allow multiple EIPs to associate to single ENI [GH-6070] * provider/clc: Override default `account` alias in provider config [GH-5785] * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] From 26bc88a1cc406e32e985042846c65669da43e9f2 Mon Sep 17 00:00:00 2001 From: Ricard Clau Date: Fri, 8 Apr 2016 22:22:36 +0100 Subject: [PATCH 035/665] error checks for vsphere create and delete folder (#6095) --- builtin/providers/vsphere/resource_vsphere_folder.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_folder.go b/builtin/providers/vsphere/resource_vsphere_folder.go index 82289f3cfbd1..1a39eb90108f 100644 --- a/builtin/providers/vsphere/resource_vsphere_folder.go +++ b/builtin/providers/vsphere/resource_vsphere_folder.go @@ -58,7 +58,10 @@ func resourceVSphereFolderCreate(d *schema.ResourceData, meta interface{}) error f.datacenter = v.(string) } - createFolder(client, &f) + err := createFolder(client, &f) + if err != nil { + return err + } d.Set("existing_path", f.existingPath) d.SetId(fmt.Sprintf("%v/%v", f.datacenter, f.path)) @@ -153,7 +156,10 @@ func resourceVSphereFolderDelete(d *schema.ResourceData, meta interface{}) error client := meta.(*govmomi.Client) - deleteFolder(client, &f) + err := deleteFolder(client, &f) + if err != nil { + return err + } d.SetId("") return nil From a7f7e25032ba7be1e5bc7bea47705201d53e1889 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Fri, 8 Apr 2016 16:23:30 -0500 Subject: [PATCH 036/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7baee357f8..d8d574f25d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ BUG FIXES: * provider/docker: Docker Image will be deleted on destroy [GH-5801] * provider/openstack: Fix resizing when Flavor Name changes [GH-6020] * provider/openstack: Fix Disabling DHCP on Subnets [GH-6052] + * provider/vsphere: Add error handling to `vsphere_folder` [GH-6095] ## 0.6.14 (March 21, 2016) From 68a2a2299ebb7479003953db83d84046de08ba09 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 8 Apr 2016 17:28:54 -0400 Subject: [PATCH 037/665] Use schema funcs for reading values from the env --- builtin/providers/openstack/provider.go | 37 +++++-------------- ...source_openstack_blockstorage_volume_v1.go | 2 +- ...esource_openstack_compute_floatingip_v2.go | 4 +- .../resource_openstack_compute_instance_v2.go | 6 +-- .../resource_openstack_compute_keypair_v2.go | 2 +- .../resource_openstack_compute_secgroup_v2.go | 2 +- ...source_openstack_compute_servergroup_v2.go | 2 +- .../resource_openstack_fw_firewall_v1.go | 2 +- .../resource_openstack_fw_policy_v1.go | 2 +- .../resource_openstack_fw_rule_v1.go | 2 +- .../resource_openstack_lb_member_v1.go | 2 +- .../resource_openstack_lb_monitor_v1.go | 2 +- .../resource_openstack_lb_pool_v1.go | 4 +- .../openstack/resource_openstack_lb_vip_v1.go | 2 +- ...urce_openstack_networking_floatingip_v2.go | 4 +- ...esource_openstack_networking_network_v2.go | 2 +- .../resource_openstack_networking_port_v2.go | 2 +- ...penstack_networking_router_interface_v2.go | 2 +- ...resource_openstack_networking_router_v2.go | 2 +- ...resource_openstack_networking_subnet_v2.go | 2 +- ...ce_openstack_objectstorage_container_v1.go | 2 +- builtin/providers/powerdns/provider.go | 16 +------- 22 files changed, 36 insertions(+), 67 deletions(-) diff --git a/builtin/providers/openstack/provider.go b/builtin/providers/openstack/provider.go index a6d126ec4b0b..2e5a1f8e74d3 100644 --- a/builtin/providers/openstack/provider.go +++ b/builtin/providers/openstack/provider.go @@ -1,8 +1,6 @@ package openstack import ( - "os" - "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) @@ -14,12 +12,12 @@ func Provider() terraform.ResourceProvider { "auth_url": &schema.Schema{ Type: schema.TypeString, Required: true, - DefaultFunc: envDefaultFunc("OS_AUTH_URL"), + DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_URL", nil), }, "user_name": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFunc("OS_USERNAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_USERNAME", nil), }, "user_id": &schema.Schema{ Type: schema.TypeString, @@ -34,27 +32,27 @@ func Provider() terraform.ResourceProvider { "tenant_name": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFunc("OS_TENANT_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_TENANT_NAME", nil), }, "password": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFunc("OS_PASSWORD"), + DefaultFunc: schema.EnvDefaultFunc("OS_PASSWORD", nil), }, "api_key": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_AUTH_TOKEN"), + DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_TOKEN", ""), }, "domain_id": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_DOMAIN_ID"), + DefaultFunc: schema.EnvDefaultFunc("OS_DOMAIN_ID", ""), }, "domain_name": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_DOMAIN_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_DOMAIN_NAME", ""), }, "insecure": &schema.Schema{ Type: schema.TypeBool, @@ -64,12 +62,12 @@ func Provider() terraform.ResourceProvider { "endpoint_type": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_ENDPOINT_TYPE"), + DefaultFunc: schema.EnvDefaultFunc("OS_ENDPOINT_TYPE", ""), }, "cacert_file": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_CACERT"), + DefaultFunc: schema.EnvDefaultFunc("OS_CACERT", ""), }, }, @@ -122,20 +120,3 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) { return &config, nil } - -func envDefaultFunc(k string) schema.SchemaDefaultFunc { - return func() (interface{}, error) { - if v := os.Getenv(k); v != "" { - return v, nil - } - - return nil, nil - } -} - -func envDefaultFuncAllowMissing(k string) schema.SchemaDefaultFunc { - return func() (interface{}, error) { - v := os.Getenv(k) - return v, nil - } -} diff --git a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go index ba7249df0325..05328fa18b4a 100644 --- a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go +++ b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go @@ -26,7 +26,7 @@ func resourceBlockStorageVolumeV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "size": &schema.Schema{ Type: schema.TypeInt, diff --git a/builtin/providers/openstack/resource_openstack_compute_floatingip_v2.go b/builtin/providers/openstack/resource_openstack_compute_floatingip_v2.go index 323ec7608dce..731b5f941f47 100644 --- a/builtin/providers/openstack/resource_openstack_compute_floatingip_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_floatingip_v2.go @@ -20,14 +20,14 @@ func resourceComputeFloatingIPV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "pool": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFunc("OS_POOL_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_POOL_NAME", nil), }, "address": &schema.Schema{ diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index b863c5114648..87cd4e5800c0 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -38,7 +38,7 @@ func resourceComputeInstanceV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, @@ -62,14 +62,14 @@ func resourceComputeInstanceV2() *schema.Resource { Optional: true, ForceNew: false, Computed: true, - DefaultFunc: envDefaultFunc("OS_FLAVOR_ID"), + DefaultFunc: schema.EnvDefaultFunc("OS_FLAVOR_ID", nil), }, "flavor_name": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: false, Computed: true, - DefaultFunc: envDefaultFunc("OS_FLAVOR_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_FLAVOR_NAME", nil), }, "floating_ip": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_compute_keypair_v2.go b/builtin/providers/openstack/resource_openstack_compute_keypair_v2.go index bc9a28b38dcc..dcc476bd40e0 100644 --- a/builtin/providers/openstack/resource_openstack_compute_keypair_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_keypair_v2.go @@ -19,7 +19,7 @@ func resourceComputeKeypairV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_compute_secgroup_v2.go b/builtin/providers/openstack/resource_openstack_compute_secgroup_v2.go index d8d559b9b047..9d8e79038464 100644 --- a/builtin/providers/openstack/resource_openstack_compute_secgroup_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_secgroup_v2.go @@ -25,7 +25,7 @@ func resourceComputeSecGroupV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_compute_servergroup_v2.go b/builtin/providers/openstack/resource_openstack_compute_servergroup_v2.go index 59fef25f7f27..64cc61ff2c39 100644 --- a/builtin/providers/openstack/resource_openstack_compute_servergroup_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_servergroup_v2.go @@ -20,7 +20,7 @@ func resourceComputeServerGroupV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_fw_firewall_v1.go b/builtin/providers/openstack/resource_openstack_fw_firewall_v1.go index b4099a7cb04e..44c93a4c826c 100644 --- a/builtin/providers/openstack/resource_openstack_fw_firewall_v1.go +++ b/builtin/providers/openstack/resource_openstack_fw_firewall_v1.go @@ -23,7 +23,7 @@ func resourceFWFirewallV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_fw_policy_v1.go b/builtin/providers/openstack/resource_openstack_fw_policy_v1.go index f75c0d8bd321..c33bde8bb392 100644 --- a/builtin/providers/openstack/resource_openstack_fw_policy_v1.go +++ b/builtin/providers/openstack/resource_openstack_fw_policy_v1.go @@ -22,7 +22,7 @@ func resourceFWPolicyV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_fw_rule_v1.go b/builtin/providers/openstack/resource_openstack_fw_rule_v1.go index 535a6c2059a2..15590f019cc0 100644 --- a/builtin/providers/openstack/resource_openstack_fw_rule_v1.go +++ b/builtin/providers/openstack/resource_openstack_fw_rule_v1.go @@ -21,7 +21,7 @@ func resourceFWRuleV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_lb_member_v1.go b/builtin/providers/openstack/resource_openstack_lb_member_v1.go index 46d62e8d20a1..4fbf3dcca53a 100644 --- a/builtin/providers/openstack/resource_openstack_lb_member_v1.go +++ b/builtin/providers/openstack/resource_openstack_lb_member_v1.go @@ -24,7 +24,7 @@ func resourceLBMemberV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "tenant_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_lb_monitor_v1.go b/builtin/providers/openstack/resource_openstack_lb_monitor_v1.go index 5599237766b6..71ace9286583 100644 --- a/builtin/providers/openstack/resource_openstack_lb_monitor_v1.go +++ b/builtin/providers/openstack/resource_openstack_lb_monitor_v1.go @@ -25,7 +25,7 @@ func resourceLBMonitorV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "tenant_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_lb_pool_v1.go b/builtin/providers/openstack/resource_openstack_lb_pool_v1.go index 2853cad4cf7a..6eaac9a130d7 100644 --- a/builtin/providers/openstack/resource_openstack_lb_pool_v1.go +++ b/builtin/providers/openstack/resource_openstack_lb_pool_v1.go @@ -28,7 +28,7 @@ func resourceLBPoolV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, @@ -66,7 +66,7 @@ func resourceLBPoolV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "tenant_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_lb_vip_v1.go b/builtin/providers/openstack/resource_openstack_lb_vip_v1.go index 449ba36501c7..3bbcba56dc86 100644 --- a/builtin/providers/openstack/resource_openstack_lb_vip_v1.go +++ b/builtin/providers/openstack/resource_openstack_lb_vip_v1.go @@ -24,7 +24,7 @@ func resourceLBVipV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go index 4ec8b0a72096..cdd85fc4a625 100644 --- a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go @@ -26,7 +26,7 @@ func resourceNetworkingFloatingIPV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "address": &schema.Schema{ Type: schema.TypeString, @@ -36,7 +36,7 @@ func resourceNetworkingFloatingIPV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFunc("OS_POOL_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_POOL_NAME", nil), }, "port_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_network_v2.go b/builtin/providers/openstack/resource_openstack_networking_network_v2.go index a4d05cec17c5..4c3f4da17c88 100644 --- a/builtin/providers/openstack/resource_openstack_networking_network_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_network_v2.go @@ -25,7 +25,7 @@ func resourceNetworkingNetworkV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_port_v2.go b/builtin/providers/openstack/resource_openstack_networking_port_v2.go index 71b0d729ef94..73fa8da45607 100644 --- a/builtin/providers/openstack/resource_openstack_networking_port_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_port_v2.go @@ -24,7 +24,7 @@ func resourceNetworkingPortV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go index a744daf07332..abda7cfcab35 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go @@ -24,7 +24,7 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "router_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_router_v2.go b/builtin/providers/openstack/resource_openstack_networking_router_v2.go index fc0146a6ebe4..7b5f3b8c25a8 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_v2.go @@ -24,7 +24,7 @@ func resourceNetworkingRouterV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go index c3ca944f4f45..2b86850da4d5 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go @@ -24,7 +24,7 @@ func resourceNetworkingSubnetV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "network_id": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/openstack/resource_openstack_objectstorage_container_v1.go b/builtin/providers/openstack/resource_openstack_objectstorage_container_v1.go index b476a4080e36..dc0ed9b69401 100644 --- a/builtin/providers/openstack/resource_openstack_objectstorage_container_v1.go +++ b/builtin/providers/openstack/resource_openstack_objectstorage_container_v1.go @@ -20,7 +20,7 @@ func resourceObjectStorageContainerV1() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"), + DefaultFunc: schema.EnvDefaultFunc("OS_REGION_NAME", ""), }, "name": &schema.Schema{ Type: schema.TypeString, diff --git a/builtin/providers/powerdns/provider.go b/builtin/providers/powerdns/provider.go index c4ef5c786ff7..b1d1e339be63 100644 --- a/builtin/providers/powerdns/provider.go +++ b/builtin/providers/powerdns/provider.go @@ -1,8 +1,6 @@ package powerdns import ( - "os" - "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) @@ -13,13 +11,13 @@ func Provider() terraform.ResourceProvider { "api_key": { Type: schema.TypeString, Required: true, - DefaultFunc: envDefaultFunc("PDNS_API_KEY"), + DefaultFunc: schema.EnvDefaultFunc("PDNS_API_KEY", nil), Description: "REST API authentication key", }, "server_url": { Type: schema.TypeString, Required: true, - DefaultFunc: envDefaultFunc("PDNS_SERVER_URL"), + DefaultFunc: schema.EnvDefaultFunc("PDNS_SERVER_URL", nil), Description: "Location of PowerDNS server", }, }, @@ -40,13 +38,3 @@ func providerConfigure(data *schema.ResourceData) (interface{}, error) { return config.Client() } - -func envDefaultFunc(k string) schema.SchemaDefaultFunc { - return func() (interface{}, error) { - if v := os.Getenv(k); v != "" { - return v, nil - } - - return nil, nil - } -} From 5136462cda3338399a5cbf4d861272b817bdff56 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 8 Apr 2016 18:51:56 -0500 Subject: [PATCH 038/665] deps: Fix Godep.json for HCL --- Godeps/Godeps.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 82fcb75c02e1..1d1a089d92ce 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -714,7 +714,7 @@ }, { "ImportPath": "github.com/hashicorp/hcl/hcl/fmtcmd", - "Rev": "71c7409f1abba841e528a80556ed2c67671744c3" + "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/parser", @@ -722,7 +722,7 @@ }, { "ImportPath": "github.com/hashicorp/hcl/hcl/printer", - "Rev": "71c7409f1abba841e528a80556ed2c67671744c3" + "Rev": "2604f3bda7e8960c1be1063709e7d7f0765048d0" }, { "ImportPath": "github.com/hashicorp/hcl/hcl/scanner", From cfc2890310166ddf4bb09d4d7279f2466a334c8c Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Sat, 9 Apr 2016 21:56:06 +1000 Subject: [PATCH 039/665] Remove TF_QUICKDEV environment variable This environment variable doesn't seem to be used, the last usage was removed in 6fe27036650adc8bc9237d033dd9d18c517892a1. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4648ef234a9a..f98d6a5f0c58 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ dev: fmtcheck generate @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" quickdev: generate - @TF_QUICKDEV=1 TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" + @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" # Shorthand for quickly building the core of Terraform. Note that some # changes will require a rebuild of everything, in which case the dev From 44fc1b5d8038732b42a088125b770be7d8f700ad Mon Sep 17 00:00:00 2001 From: Hany Fahim Date: Sat, 9 Apr 2016 11:58:57 -0400 Subject: [PATCH 040/665] Add project parameter to cloudstack_port_forward. - Add parameter to resource. - Modify read operation to pass in projectid if defined. --- .../resource_cloudstack_port_forward.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go index 46fadce4cabe..fbff933c694e 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go +++ b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go @@ -43,6 +43,12 @@ func resourceCloudStackPortForward() *schema.Resource { Default: false, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "forward": &schema.Schema{ Type: schema.TypeSet, Required: true, @@ -207,6 +213,17 @@ func resourceCloudStackPortForwardRead(d *schema.ResourceData, meta interface{}) p.SetIpaddressid(d.Id()) p.SetListall(true) + // If there is a project supplied, we retrieve and set the project id + if project, ok := d.GetOk("project"); ok { + // Retrieve the project ID + projectid, e := retrieveID(cs, "project", project.(string)) + if e != nil { + return e.Error() + } + // Set the default project ID + p.SetProjectid(projectid) + } + l, err := cs.Firewall.ListPortForwardingRules(p) if err != nil { return err From a8a3bd71df91eb019d74782334ef84d14042604b Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Fri, 8 Apr 2016 04:07:42 +0000 Subject: [PATCH 041/665] provider/openstack: Enable Token Authentication This commit enables the ability to authenticate to OpenStack by way of a Keystone Token. Tokens can provide a way to use Terraform and OpenStack with an expiring, temporary credential. The token will need to be generated out of band from Terraform. --- builtin/providers/openstack/config.go | 2 ++ builtin/providers/openstack/provider.go | 12 +++++++++--- .../docs/providers/openstack/index.html.markdown | 13 ++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/builtin/providers/openstack/config.go b/builtin/providers/openstack/config.go index 47ba00f855eb..5001c8ecad98 100644 --- a/builtin/providers/openstack/config.go +++ b/builtin/providers/openstack/config.go @@ -15,6 +15,7 @@ type Config struct { Username string UserID string Password string + Token string APIKey string IdentityEndpoint string TenantID string @@ -41,6 +42,7 @@ func (c *Config) loadAndValidate() error { Username: c.Username, UserID: c.UserID, Password: c.Password, + TokenID: c.Token, APIKey: c.APIKey, IdentityEndpoint: c.IdentityEndpoint, TenantID: c.TenantID, diff --git a/builtin/providers/openstack/provider.go b/builtin/providers/openstack/provider.go index 2e5a1f8e74d3..d917ed3fd1f8 100644 --- a/builtin/providers/openstack/provider.go +++ b/builtin/providers/openstack/provider.go @@ -17,7 +17,7 @@ func Provider() terraform.ResourceProvider { "user_name": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: schema.EnvDefaultFunc("OS_USERNAME", nil), + DefaultFunc: schema.EnvDefaultFunc("OS_USERNAME", ""), }, "user_id": &schema.Schema{ Type: schema.TypeString, @@ -37,13 +37,18 @@ func Provider() terraform.ResourceProvider { "password": &schema.Schema{ Type: schema.TypeString, Optional: true, - DefaultFunc: schema.EnvDefaultFunc("OS_PASSWORD", nil), + DefaultFunc: schema.EnvDefaultFunc("OS_PASSWORD", ""), }, - "api_key": &schema.Schema{ + "token": &schema.Schema{ Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_TOKEN", ""), }, + "api_key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("OS_API_KEY", ""), + }, "domain_id": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -104,6 +109,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) { Username: d.Get("user_name").(string), UserID: d.Get("user_id").(string), Password: d.Get("password").(string), + Token: d.Get("token").(string), APIKey: d.Get("api_key").(string), TenantID: d.Get("tenant_id").(string), TenantName: d.Get("tenant_name").(string), diff --git a/website/source/docs/providers/openstack/index.html.markdown b/website/source/docs/providers/openstack/index.html.markdown index 52f94e46abc6..3a044ee62aea 100644 --- a/website/source/docs/providers/openstack/index.html.markdown +++ b/website/source/docs/providers/openstack/index.html.markdown @@ -46,7 +46,18 @@ The following arguments are supported: * `password` - (Optional; Required if not using `api_key`) If omitted, the `OS_PASSWORD` environment variable is used. -* `api_key` - (Optional; Required if not using `password`) +* `token` - (Optional; Required if not using `user_name` and `password`) + A token is an expiring, temporary means of access issued via the + Keystone service. By specifying a token, you do not have to + specify a username/password combination, since the token was + already created by a username/password out of band of Terraform. + If ommitted, the `OS_AUTH_TOKEN` environment variable is used. + +* `api_key` - (Optional; Required if not using `password`) An API Key + is issued by a cloud provider as alternative password. Unless + your cloud provider has documentation referencing an API Key, + you can safely ignore this argument. If omitted, the `OS_API_KEY` + environment variable is used. * `domain_id` - (Optional) If omitted, the `OS_DOMAIN_ID` environment variable is used. From 7e5ca60369d420a391f11a6b5d69a376437d9f14 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 8 Apr 2016 11:01:53 -0400 Subject: [PATCH 042/665] Make GCP provider "project" attribute optional --- builtin/providers/google/provider.go | 4 ++-- website/source/docs/providers/google/index.html.markdown | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/builtin/providers/google/provider.go b/builtin/providers/google/provider.go index e496b4eec843..7af7e628c741 100644 --- a/builtin/providers/google/provider.go +++ b/builtin/providers/google/provider.go @@ -33,7 +33,7 @@ func Provider() terraform.ResourceProvider { "project": &schema.Schema{ Type: schema.TypeString, - Required: true, + Required: false, DefaultFunc: schema.EnvDefaultFunc("GOOGLE_PROJECT", nil), }, @@ -122,7 +122,7 @@ func validateAccountFile(v interface{}, k string) (warnings []string, errors []e errors = append(errors, fmt.Errorf("Error loading Account File: %s", err)) } if wasPath { - warnings = append(warnings, `account_file was provided as a path instead of + warnings = append(warnings, `account_file was provided as a path instead of as file contents. This support will be removed in the future. Please update your configuration to use ${file("filename.json")} instead.`) } diff --git a/website/source/docs/providers/google/index.html.markdown b/website/source/docs/providers/google/index.html.markdown index c7cf44e985c1..5aee7215420d 100644 --- a/website/source/docs/providers/google/index.html.markdown +++ b/website/source/docs/providers/google/index.html.markdown @@ -42,12 +42,15 @@ The following keys can be used to configure the provider. can also be specified with the `GOOGLE_CREDENTIALS` or `GOOGLE_CLOUD_KEYFILE_JSON` shell environment variable, containing the contents of the credentials file. -* `project` - (Required) The ID of the project to apply any resources to. This - can also be specified with the `GOOGLE_PROJECT` shell environment variable. - * `region` - (Required) The region to operate under. This can also be specified with the `GOOGLE_REGION` shell environment variable. +* `project` - (Optional) The ID of the project to apply resources in. This + can also be specified with the `GOOGLE_PROJECT` shell environment variable. + If unspecified, users will need to specify the `project` attribute for + all resources. If specified, resources which do not depend on a project will + ignore this value. + The following keys are supported for backwards compatibility, and may be removed in a future version: From d5a9e9b554fd54cc77b82e8aeee75b84fd54962f Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 10 Apr 2016 12:22:44 -0400 Subject: [PATCH 043/665] Deprecate unused "region" attribute in gcp global_forwarding_rule --- .../resource_compute_global_forwarding_rule.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/providers/google/resource_compute_global_forwarding_rule.go b/builtin/providers/google/resource_compute_global_forwarding_rule.go index ce987f716524..dc7a852c7451 100644 --- a/builtin/providers/google/resource_compute_global_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_global_forwarding_rule.go @@ -49,12 +49,6 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { ForceNew: true, }, - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "self_link": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -64,6 +58,13 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { Type: schema.TypeString, Required: true, }, + + "region": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please remove this attribute (it was never used)", + }, }, } } From fda23a3a3176264e9af0e61b42ad96745d170e0c Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 10 Apr 2016 12:32:19 -0400 Subject: [PATCH 044/665] Switch the order of gcp buildNetworks func to be more go-like The current implementation returns error as the first parameter, but it is usually the last parameter. --- .../resource_compute_instance_template.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index 4128fbcccb10..ea5ed35d657c 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -337,7 +337,7 @@ func buildDisks(d *schema.ResourceData, meta interface{}) ([]*compute.AttachedDi return disks, nil } -func buildNetworks(d *schema.ResourceData, meta interface{}) (error, []*compute.NetworkInterface) { +func buildNetworks(d *schema.ResourceData, meta interface{}) ([]*compute.NetworkInterface, error) { // Build up the list of networks config := meta.(*Config) @@ -355,20 +355,19 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) (error, []*compute. } if networkName == "" && subnetworkName == "" { - return fmt.Errorf("network or subnetwork must be provided"), nil + return nil, fmt.Errorf("network or subnetwork must be provided") } if networkName != "" && subnetworkName != "" { - return fmt.Errorf("network or subnetwork must not both be provided"), nil + return nil, fmt.Errorf("network or subnetwork must not both be provided") } var networkLink, subnetworkLink string if networkName != "" { network, err := config.clientCompute.Networks.Get( - config.Project, networkName).Do() + project, networkName).Do() if err != nil { - return fmt.Errorf( - "Error referencing network '%s': %s", - networkName, err), nil + return nil, fmt.Errorf("Error referencing network '%s': %s", + networkName, err) } networkLink = network.SelfLink } else { @@ -378,11 +377,11 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) (error, []*compute. region = config.Region } subnetwork, err := config.clientCompute.Subnetworks.Get( - config.Project, region, subnetworkName).Do() + project, region, subnetworkName).Do() if err != nil { - return fmt.Errorf( + return nil, fmt.Errorf( "Error referencing subnetwork '%s' in region '%s': %s", - subnetworkName, region, err), nil + subnetworkName, region, err) } subnetworkLink = subnetwork.SelfLink } @@ -404,7 +403,7 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) (error, []*compute. networkInterfaces = append(networkInterfaces, &iface) } - return nil, networkInterfaces + return networkInterfaces, nil } func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interface{}) error { @@ -425,7 +424,7 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac return err } instanceProperties.Metadata = metadata - err, networks := buildNetworks(d, meta) + networks, err := buildNetworks(d, meta) if err != nil { return err } From bacf5abf3cbf853868ce04b7da1ad644b66f8f40 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 10 Apr 2016 12:59:57 -0400 Subject: [PATCH 045/665] Accept "project" as an attribute to GCP resources This is the first step in removing the config dependency on "project". This change is backwards-compatible because the value for this new attribute defaults to the value from the provider. --- builtin/providers/google/provider.go | 32 ++++++- .../google/resource_compute_address.go | 52 ++++++++--- .../google/resource_compute_autoscaler.go | 37 ++++++-- .../resource_compute_backend_service.go | 34 +++++++- .../providers/google/resource_compute_disk.go | 31 +++++-- .../google/resource_compute_firewall.go | 38 ++++++-- .../resource_compute_forwarding_rule.go | 66 +++++++++++--- .../google/resource_compute_global_address.go | 27 +++++- ...resource_compute_global_forwarding_rule.go | 34 +++++++- .../resource_compute_http_health_check.go | 34 +++++++- .../resource_compute_https_health_check.go | 34 +++++++- .../google/resource_compute_instance.go | 54 +++++++++--- .../google/resource_compute_instance_group.go | 44 ++++++++-- ...resource_compute_instance_group_manager.go | 46 +++++++--- .../resource_compute_instance_template.go | 50 ++++++++--- .../google/resource_compute_network.go | 27 +++++- .../resource_compute_project_metadata.go | 60 +++++++++---- .../google/resource_compute_route.go | 31 +++++-- .../resource_compute_ssl_certificate.go | 27 +++++- .../google/resource_compute_subnetwork.go | 32 ++++++- .../resource_compute_target_http_proxy.go | 34 +++++++- .../resource_compute_target_https_proxy.go | 38 ++++++-- .../google/resource_compute_target_pool.go | 86 ++++++++++++++----- .../google/resource_compute_url_map.go | 37 ++++++-- .../google/resource_compute_vpn_gateway.go | 45 ++++++++-- .../google/resource_compute_vpn_tunnel.go | 51 ++++++++--- .../google/resource_container_cluster.go | 40 +++++++-- .../google/resource_dns_managed_zone.go | 27 +++++- .../google/resource_dns_record_set.go | 31 +++++-- .../google/resource_pubsub_subscription.go | 15 +++- .../providers/google/resource_pubsub_topic.go | 13 ++- .../providers/google/resource_sql_database.go | 23 ++++- .../google/resource_sql_database_instance.go | 37 ++++++-- builtin/providers/google/resource_sql_user.go | 30 ++++++- .../google/resource_storage_bucket.go | 12 ++- 35 files changed, 1080 insertions(+), 229 deletions(-) diff --git a/builtin/providers/google/provider.go b/builtin/providers/google/provider.go index 7af7e628c741..8fd5339f51b3 100644 --- a/builtin/providers/google/provider.go +++ b/builtin/providers/google/provider.go @@ -33,8 +33,8 @@ func Provider() terraform.ResourceProvider { "project": &schema.Schema{ Type: schema.TypeString, - Required: false, - DefaultFunc: schema.EnvDefaultFunc("GOOGLE_PROJECT", nil), + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("GOOGLE_PROJECT", ""), }, "region": &schema.Schema{ @@ -158,3 +158,31 @@ func getRegionFromZone(zone string) string { } return "" } + +// getRegion reads the "region" field from the given resource data and falls +// back to the provider's value if not given. If the provider's value is not +// given, an error is returned. +func getRegion(d *schema.ResourceData, config *Config) (string, error) { + res, ok := d.GetOk("region") + if !ok { + if config.Region != "" { + return config.Region, nil + } + return "", fmt.Errorf("%q: required field is not set", "region") + } + return res.(string), nil +} + +// getProject reads the "project" field from the given resource data and falls +// back to the provider's value if not given. If the provider's value is not +// given, an error is returned. +func getProject(d *schema.ResourceData, config *Config) (string, error) { + res, ok := d.GetOk("project") + if !ok { + if config.Project != "" { + return config.Project, nil + } + return "", fmt.Errorf("%q: required field is not set", "project") + } + return res.(string), nil +} diff --git a/builtin/providers/google/resource_compute_address.go b/builtin/providers/google/resource_compute_address.go index 15fa132723e6..4567e4280b9c 100644 --- a/builtin/providers/google/resource_compute_address.go +++ b/builtin/providers/google/resource_compute_address.go @@ -37,26 +37,33 @@ func resourceComputeAddress() *schema.Resource { Optional: true, ForceNew: true, }, - }, - } -} -func getOptionalRegion(d *schema.ResourceData, config *Config) string { - if res, ok := d.GetOk("region"); !ok { - return config.Region - } else { - return res.(string) + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, } } func resourceComputeAddressCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } // Build the address parameter addr := &compute.Address{Name: d.Get("name").(string)} op, err := config.clientCompute.Addresses.Insert( - config.Project, region, addr).Do() + project, region, addr).Do() if err != nil { return fmt.Errorf("Error creating address: %s", err) } @@ -75,10 +82,18 @@ func resourceComputeAddressCreate(d *schema.ResourceData, meta interface{}) erro func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } addr, err := config.clientCompute.Addresses.Get( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -100,11 +115,20 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error func resourceComputeAddressDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the address log.Printf("[DEBUG] address delete request") op, err := config.clientCompute.Addresses.Delete( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting address: %s", err) } diff --git a/builtin/providers/google/resource_compute_autoscaler.go b/builtin/providers/google/resource_compute_autoscaler.go index 89cc41b07528..7fd8819de8ce 100644 --- a/builtin/providers/google/resource_compute_autoscaler.go +++ b/builtin/providers/google/resource_compute_autoscaler.go @@ -115,12 +115,17 @@ func resourceComputeAutoscaler() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } func buildAutoscaler(d *schema.ResourceData) (*compute.Autoscaler, error) { - // Build the parameter scaler := &compute.Autoscaler{ Name: d.Get("name").(string), @@ -200,10 +205,15 @@ func buildAutoscaler(d *schema.ResourceData) (*compute.Autoscaler, error) { func resourceComputeAutoscalerCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Get the zone log.Printf("[DEBUG] Loading zone: %s", d.Get("zone").(string)) zone, err := config.clientCompute.Zones.Get( - config.Project, d.Get("zone").(string)).Do() + project, d.Get("zone").(string)).Do() if err != nil { return fmt.Errorf( "Error loading zone '%s': %s", d.Get("zone").(string), err) @@ -215,7 +225,7 @@ func resourceComputeAutoscalerCreate(d *schema.ResourceData, meta interface{}) e } op, err := config.clientCompute.Autoscalers.Insert( - config.Project, zone.Name, scaler).Do() + project, zone.Name, scaler).Do() if err != nil { return fmt.Errorf("Error creating Autoscaler: %s", err) } @@ -234,9 +244,14 @@ func resourceComputeAutoscalerCreate(d *schema.ResourceData, meta interface{}) e func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) scaler, err := config.clientCompute.Autoscalers.Get( - config.Project, zone, d.Id()).Do() + project, zone, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -257,6 +272,11 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) scaler, err := buildAutoscaler(d) @@ -265,7 +285,7 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e } op, err := config.clientCompute.Autoscalers.Patch( - config.Project, zone, d.Id(), scaler).Do() + project, zone, d.Id(), scaler).Do() if err != nil { return fmt.Errorf("Error updating Autoscaler: %s", err) } @@ -284,9 +304,14 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e func resourceComputeAutoscalerDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) op, err := config.clientCompute.Autoscalers.Delete( - config.Project, zone, d.Id()).Do() + project, zone, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting autoscaler: %s", err) } diff --git a/builtin/providers/google/resource_compute_backend_service.go b/builtin/providers/google/resource_compute_backend_service.go index 2159073c21c6..f0402478177c 100644 --- a/builtin/providers/google/resource_compute_backend_service.go +++ b/builtin/providers/google/resource_compute_backend_service.go @@ -121,6 +121,12 @@ func resourceComputeBackendService() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -159,9 +165,14 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ service.TimeoutSec = int64(v.(int)) } + project, err := getProject(d, config) + if err != nil { + return err + } + log.Printf("[DEBUG] Creating new Backend Service: %#v", service) op, err := config.clientCompute.BackendServices.Insert( - config.Project, &service).Do() + project, &service).Do() if err != nil { return fmt.Errorf("Error creating backend service: %s", err) } @@ -181,8 +192,13 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + service, err := config.clientCompute.BackendServices.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -211,6 +227,11 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + hc := d.Get("health_checks").(*schema.Set).List() healthChecks := make([]string, 0, len(hc)) for _, v := range hc { @@ -241,7 +262,7 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Updating existing Backend Service %q: %#v", d.Id(), service) op, err := config.clientCompute.BackendServices.Update( - config.Project, d.Id(), &service).Do() + project, d.Id(), &service).Do() if err != nil { return fmt.Errorf("Error updating backend service: %s", err) } @@ -259,9 +280,14 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + log.Printf("[DEBUG] Deleting backend service %s", d.Id()) op, err := config.clientCompute.BackendServices.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting backend service: %s", err) } diff --git a/builtin/providers/google/resource_compute_disk.go b/builtin/providers/google/resource_compute_disk.go index 1df66b9bb98d..62d0ea3e1c2b 100644 --- a/builtin/providers/google/resource_compute_disk.go +++ b/builtin/providers/google/resource_compute_disk.go @@ -56,6 +56,12 @@ func resourceComputeDisk() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -63,10 +69,15 @@ func resourceComputeDisk() *schema.Resource { func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Get the zone log.Printf("[DEBUG] Loading zone: %s", d.Get("zone").(string)) zone, err := config.clientCompute.Zones.Get( - config.Project, d.Get("zone").(string)).Do() + project, d.Get("zone").(string)).Do() if err != nil { return fmt.Errorf( "Error loading zone '%s': %s", d.Get("zone").(string), err) @@ -107,7 +118,7 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { snapshotName := v.(string) log.Printf("[DEBUG] Loading snapshot: %s", snapshotName) snapshotData, err := config.clientCompute.Snapshots.Get( - config.Project, snapshotName).Do() + project, snapshotName).Do() if err != nil { return fmt.Errorf( @@ -119,7 +130,7 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { } op, err := config.clientCompute.Disks.Insert( - config.Project, d.Get("zone").(string), disk).Do() + project, d.Get("zone").(string), disk).Do() if err != nil { return fmt.Errorf("Error creating disk: %s", err) } @@ -137,8 +148,13 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + disk, err := config.clientCompute.Disks.Get( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Disk %q because it's gone", d.Get("name").(string)) @@ -159,9 +175,14 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { func resourceComputeDiskDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the disk op, err := config.clientCompute.Disks.Delete( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting disk: %s", err) } diff --git a/builtin/providers/google/resource_compute_firewall.go b/builtin/providers/google/resource_compute_firewall.go index 3d5d8e59548f..1676b22a6208 100644 --- a/builtin/providers/google/resource_compute_firewall.go +++ b/builtin/providers/google/resource_compute_firewall.go @@ -83,6 +83,12 @@ func resourceComputeFirewall() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -113,13 +119,18 @@ func resourceComputeFirewallAllowHash(v interface{}) int { func resourceComputeFirewallCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + firewall, err := resourceFirewall(d, meta) if err != nil { return err } op, err := config.clientCompute.Firewalls.Insert( - config.Project, firewall).Do() + project, firewall).Do() if err != nil { return fmt.Errorf("Error creating firewall: %s", err) } @@ -138,8 +149,13 @@ func resourceComputeFirewallCreate(d *schema.ResourceData, meta interface{}) err func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + firewall, err := config.clientCompute.Firewalls.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -160,6 +176,11 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) firewall, err := resourceFirewall(d, meta) @@ -168,7 +189,7 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err } op, err := config.clientCompute.Firewalls.Update( - config.Project, d.Id(), firewall).Do() + project, d.Id(), firewall).Do() if err != nil { return fmt.Errorf("Error updating firewall: %s", err) } @@ -186,9 +207,14 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err func resourceComputeFirewallDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the firewall op, err := config.clientCompute.Firewalls.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting firewall: %s", err) } @@ -207,9 +233,11 @@ func resourceFirewall( meta interface{}) (*compute.Firewall, error) { config := meta.(*Config) + project, _ := getProject(d, config) + // Look up the network to attach the firewall to network, err := config.clientCompute.Networks.Get( - config.Project, d.Get("network").(string)).Do() + project, d.Get("network").(string)).Do() if err != nil { return nil, fmt.Errorf("Error reading network: %s", err) } diff --git a/builtin/providers/google/resource_compute_forwarding_rule.go b/builtin/providers/google/resource_compute_forwarding_rule.go index e1cbdc46c9b0..0f71627376f4 100644 --- a/builtin/providers/google/resource_compute_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_forwarding_rule.go @@ -49,12 +49,6 @@ func resourceComputeForwardingRule() *schema.Resource { ForceNew: true, }, - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "self_link": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -65,6 +59,18 @@ func resourceComputeForwardingRule() *schema.Resource { Required: true, ForceNew: false, }, + + "region": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -72,7 +78,15 @@ func resourceComputeForwardingRule() *schema.Resource { func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } frule := &compute.ForwardingRule{ IPAddress: d.Get("ip_address").(string), @@ -85,7 +99,7 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] ForwardingRule insert request: %#v", frule) op, err := config.clientCompute.ForwardingRules.Insert( - config.Project, region, frule).Do() + project, region, frule).Do() if err != nil { return fmt.Errorf("Error creating ForwardingRule: %s", err) } @@ -104,7 +118,15 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } d.Partial(true) @@ -112,7 +134,7 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ target_name := d.Get("target").(string) target_ref := &compute.TargetReference{Target: target_name} op, err := config.clientCompute.ForwardingRules.SetTarget( - config.Project, region, d.Id(), target_ref).Do() + project, region, d.Id(), target_ref).Do() if err != nil { return fmt.Errorf("Error updating target: %s", err) } @@ -133,10 +155,18 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } frule, err := config.clientCompute.ForwardingRules.Get( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Forwarding Rule %q because it's gone", d.Get("name").(string)) @@ -159,12 +189,20 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } // Delete the ForwardingRule log.Printf("[DEBUG] ForwardingRule delete request") op, err := config.clientCompute.ForwardingRules.Delete( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting ForwardingRule: %s", err) } diff --git a/builtin/providers/google/resource_compute_global_address.go b/builtin/providers/google/resource_compute_global_address.go index 58d3f5e8e776..5549022393a5 100644 --- a/builtin/providers/google/resource_compute_global_address.go +++ b/builtin/providers/google/resource_compute_global_address.go @@ -31,6 +31,12 @@ func resourceComputeGlobalAddress() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -38,10 +44,15 @@ func resourceComputeGlobalAddress() *schema.Resource { func resourceComputeGlobalAddressCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the address parameter addr := &compute.Address{Name: d.Get("name").(string)} op, err := config.clientCompute.GlobalAddresses.Insert( - config.Project, addr).Do() + project, addr).Do() if err != nil { return fmt.Errorf("Error creating address: %s", err) } @@ -60,8 +71,13 @@ func resourceComputeGlobalAddressCreate(d *schema.ResourceData, meta interface{} func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + addr, err := config.clientCompute.GlobalAddresses.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Global Address %q because it's gone", d.Get("name").(string)) @@ -83,10 +99,15 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{}) func resourceComputeGlobalAddressDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the address log.Printf("[DEBUG] address delete request") op, err := config.clientCompute.GlobalAddresses.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting address: %s", err) } diff --git a/builtin/providers/google/resource_compute_global_forwarding_rule.go b/builtin/providers/google/resource_compute_global_forwarding_rule.go index dc7a852c7451..5c41675e1833 100644 --- a/builtin/providers/google/resource_compute_global_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_global_forwarding_rule.go @@ -65,6 +65,12 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { ForceNew: true, Deprecated: "Please remove this attribute (it was never used)", }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -72,6 +78,11 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + frule := &compute.ForwardingRule{ IPAddress: d.Get("ip_address").(string), IPProtocol: d.Get("ip_protocol").(string), @@ -82,7 +93,7 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte } op, err := config.clientCompute.GlobalForwardingRules.Insert( - config.Project, frule).Do() + project, frule).Do() if err != nil { return fmt.Errorf("Error creating Global Forwarding Rule: %s", err) } @@ -101,13 +112,18 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) if d.HasChange("target") { target_name := d.Get("target").(string) target_ref := &compute.TargetReference{Target: target_name} op, err := config.clientCompute.GlobalForwardingRules.SetTarget( - config.Project, d.Id(), target_ref).Do() + project, d.Id(), target_ref).Do() if err != nil { return fmt.Errorf("Error updating target: %s", err) } @@ -128,8 +144,13 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + frule, err := config.clientCompute.GlobalForwardingRules.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Global Forwarding Rule %q because it's gone", d.Get("name").(string)) @@ -152,10 +173,15 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the GlobalForwardingRule log.Printf("[DEBUG] GlobalForwardingRule delete request") op, err := config.clientCompute.GlobalForwardingRules.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting GlobalForwardingRule: %s", err) } diff --git a/builtin/providers/google/resource_compute_http_health_check.go b/builtin/providers/google/resource_compute_http_health_check.go index 8ddae0b70fde..0d8eaed0b9bf 100644 --- a/builtin/providers/google/resource_compute_http_health_check.go +++ b/builtin/providers/google/resource_compute_http_health_check.go @@ -73,6 +73,12 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Optional: true, Default: 2, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -80,6 +86,11 @@ func resourceComputeHttpHealthCheck() *schema.Resource { func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter hchk := &compute.HttpHealthCheck{ Name: d.Get("name").(string), @@ -112,7 +123,7 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface log.Printf("[DEBUG] HttpHealthCheck insert request: %#v", hchk) op, err := config.clientCompute.HttpHealthChecks.Insert( - config.Project, hchk).Do() + project, hchk).Do() if err != nil { return fmt.Errorf("Error creating HttpHealthCheck: %s", err) } @@ -131,6 +142,11 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter hchk := &compute.HttpHealthCheck{ Name: d.Get("name").(string), @@ -163,7 +179,7 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface log.Printf("[DEBUG] HttpHealthCheck patch request: %#v", hchk) op, err := config.clientCompute.HttpHealthChecks.Patch( - config.Project, hchk.Name, hchk).Do() + project, hchk.Name, hchk).Do() if err != nil { return fmt.Errorf("Error patching HttpHealthCheck: %s", err) } @@ -182,8 +198,13 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + hchk, err := config.clientCompute.HttpHealthChecks.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -211,9 +232,14 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{} func resourceComputeHttpHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the HttpHealthCheck op, err := config.clientCompute.HttpHealthChecks.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting HttpHealthCheck: %s", err) } diff --git a/builtin/providers/google/resource_compute_https_health_check.go b/builtin/providers/google/resource_compute_https_health_check.go index 46affdd9e3de..64b50483dff3 100644 --- a/builtin/providers/google/resource_compute_https_health_check.go +++ b/builtin/providers/google/resource_compute_https_health_check.go @@ -73,6 +73,12 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { Optional: true, Default: 2, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -80,6 +86,11 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter hchk := &compute.HttpsHealthCheck{ Name: d.Get("name").(string), @@ -112,7 +123,7 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] HttpsHealthCheck insert request: %#v", hchk) op, err := config.clientCompute.HttpsHealthChecks.Insert( - config.Project, hchk).Do() + project, hchk).Do() if err != nil { return fmt.Errorf("Error creating HttpsHealthCheck: %s", err) } @@ -131,6 +142,11 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter hchk := &compute.HttpsHealthCheck{ Name: d.Get("name").(string), @@ -163,7 +179,7 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] HttpsHealthCheck patch request: %#v", hchk) op, err := config.clientCompute.HttpsHealthChecks.Patch( - config.Project, hchk.Name, hchk).Do() + project, hchk.Name, hchk).Do() if err != nil { return fmt.Errorf("Error patching HttpsHealthCheck: %s", err) } @@ -182,8 +198,13 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + hchk, err := config.clientCompute.HttpsHealthChecks.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing HTTPS Health Check %q because it's gone", d.Get("name").(string)) @@ -211,9 +232,14 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{ func resourceComputeHttpsHealthCheckDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the HttpsHealthCheck op, err := config.clientCompute.HttpsHealthChecks.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting HttpsHealthCheck: %s", err) } diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index 4c4632125622..a50e1c105581 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -281,13 +281,24 @@ func resourceComputeInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } func getInstance(config *Config, d *schema.ResourceData) (*compute.Instance, error) { + project, err := getProject(d, config) + if err != nil { + return nil, err + } + instance, err := config.clientCompute.Instances.Get( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Instance %q because it's gone", d.Get("name").(string)) @@ -307,10 +318,15 @@ func getInstance(config *Config, d *schema.ResourceData) (*compute.Instance, err func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Get the zone log.Printf("[DEBUG] Loading zone: %s", d.Get("zone").(string)) zone, err := config.clientCompute.Zones.Get( - config.Project, d.Get("zone").(string)).Do() + project, d.Get("zone").(string)).Do() if err != nil { return fmt.Errorf( "Error loading zone '%s': %s", d.Get("zone").(string), err) @@ -319,7 +335,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err // Get the machine type log.Printf("[DEBUG] Loading machine type: %s", d.Get("machine_type").(string)) machineType, err := config.clientCompute.MachineTypes.Get( - config.Project, zone.Name, d.Get("machine_type").(string)).Do() + project, zone.Name, d.Get("machine_type").(string)).Do() if err != nil { return fmt.Errorf( "Error loading machine type: %s", @@ -345,7 +361,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err if v, ok := d.GetOk(prefix + ".disk"); ok { diskName := v.(string) diskData, err := config.clientCompute.Disks.Get( - config.Project, zone.Name, diskName).Do() + project, zone.Name, diskName).Do() if err != nil { return fmt.Errorf( "Error loading disk '%s': %s", @@ -423,7 +439,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err // Load up the name of this network networkName := d.Get(prefix + ".source").(string) network, err := config.clientCompute.Networks.Get( - config.Project, networkName).Do() + project, networkName).Do() if err != nil { return fmt.Errorf( "Error loading network '%s': %s", @@ -458,7 +474,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Cannot specify both network and subnetwork values.") } else if networkName != "" { network, err := config.clientCompute.Networks.Get( - config.Project, networkName).Do() + project, networkName).Do() if err != nil { return fmt.Errorf( "Error referencing network '%s': %s", @@ -468,7 +484,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err } else { region := getRegionFromZone(d.Get("zone").(string)) subnetwork, err := config.clientCompute.Subnetworks.Get( - config.Project, region, subnetworkName).Do() + project, region, subnetworkName).Do() if err != nil { return fmt.Errorf( "Error referencing subnetwork '%s' in region '%s': %s", @@ -552,7 +568,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err log.Printf("[INFO] Requesting instance creation") op, err := config.clientCompute.Instances.Insert( - config.Project, zone.Name, &instance).Do() + project, zone.Name, &instance).Do() if err != nil { return fmt.Errorf("Error creating instance: %s", err) } @@ -724,6 +740,11 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) instance, err := getInstance(config, d) @@ -760,7 +781,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error updating metadata: %s", err) } op, err := config.clientCompute.Instances.SetMetadata( - config.Project, zone, d.Id(), md).Do() + project, zone, d.Id(), md).Do() if err != nil { return fmt.Errorf("Error updating metadata: %s", err) } @@ -780,7 +801,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err if d.HasChange("tags") { tags := resourceInstanceTags(d) op, err := config.clientCompute.Instances.SetTags( - config.Project, zone, d.Id(), tags).Do() + project, zone, d.Id(), tags).Do() if err != nil { return fmt.Errorf("Error updating tags: %s", err) } @@ -809,7 +830,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err scheduling.OnHostMaintenance = val.(string) } - op, err := config.clientCompute.Instances.SetScheduling(config.Project, + op, err := config.clientCompute.Instances.SetScheduling(project, zone, d.Id(), scheduling).Do() if err != nil { @@ -854,7 +875,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err // Delete any accessConfig that currently exists in instNetworkInterface for _, ac := range instNetworkInterface.AccessConfigs { op, err := config.clientCompute.Instances.DeleteAccessConfig( - config.Project, zone, d.Id(), ac.Name, networkName).Do() + project, zone, d.Id(), ac.Name, networkName).Do() if err != nil { return fmt.Errorf("Error deleting old access_config: %s", err) } @@ -873,7 +894,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err NatIP: d.Get(acPrefix + ".nat_ip").(string), } op, err := config.clientCompute.Instances.AddAccessConfig( - config.Project, zone, d.Id(), networkName, ac).Do() + project, zone, d.Id(), networkName, ac).Do() if err != nil { return fmt.Errorf("Error adding new access_config: %s", err) } @@ -895,9 +916,14 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) log.Printf("[INFO] Requesting instance deletion: %s", d.Id()) - op, err := config.clientCompute.Instances.Delete(config.Project, zone, d.Id()).Do() + op, err := config.clientCompute.Instances.Delete(project, zone, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting instance: %s", err) } diff --git a/builtin/providers/google/resource_compute_instance_group.go b/builtin/providers/google/resource_compute_instance_group.go index 284fc1631b5e..cd6d31088ccd 100644 --- a/builtin/providers/google/resource_compute_instance_group.go +++ b/builtin/providers/google/resource_compute_instance_group.go @@ -75,6 +75,12 @@ func resourceComputeInstanceGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -100,6 +106,11 @@ func validInstanceURLs(instanceUrls []string) bool { func resourceComputeInstanceGroupCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter instanceGroup := &compute.InstanceGroup{ Name: d.Get("name").(string), @@ -116,7 +127,7 @@ func resourceComputeInstanceGroupCreate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] InstanceGroup insert request: %#v", instanceGroup) op, err := config.clientCompute.InstanceGroups.Insert( - config.Project, d.Get("zone").(string), instanceGroup).Do() + project, d.Get("zone").(string), instanceGroup).Do() if err != nil { return fmt.Errorf("Error creating InstanceGroup: %s", err) } @@ -142,7 +153,7 @@ func resourceComputeInstanceGroupCreate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] InstanceGroup add instances request: %#v", addInstanceReq) op, err := config.clientCompute.InstanceGroups.AddInstances( - config.Project, d.Get("zone").(string), d.Id(), addInstanceReq).Do() + project, d.Get("zone").(string), d.Id(), addInstanceReq).Do() if err != nil { return fmt.Errorf("Error adding instances to InstanceGroup: %s", err) } @@ -160,9 +171,14 @@ func resourceComputeInstanceGroupCreate(d *schema.ResourceData, meta interface{} func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // retreive instance group instanceGroup, err := config.clientCompute.InstanceGroups.Get( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { // The resource doesn't exist anymore @@ -177,7 +193,7 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) // retreive instance group members var memberUrls []string members, err := config.clientCompute.InstanceGroups.ListInstances( - config.Project, d.Get("zone").(string), d.Id(), &compute.InstanceGroupsListInstancesRequest{ + project, d.Get("zone").(string), d.Id(), &compute.InstanceGroupsListInstancesRequest{ InstanceState: "ALL", }).Do() if err != nil { @@ -206,8 +222,13 @@ func resourceComputeInstanceGroupRead(d *schema.ResourceData, meta interface{}) func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // refresh the state incase referenced instances have been removed earlier in the run - err := resourceComputeInstanceGroupRead(d, meta) + err = resourceComputeInstanceGroupRead(d, meta) if err != nil { return fmt.Errorf("Error reading InstanceGroup: %s", err) } @@ -237,7 +258,7 @@ func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] InstanceGroup remove instances request: %#v", removeReq) removeOp, err := config.clientCompute.InstanceGroups.RemoveInstances( - config.Project, d.Get("zone").(string), d.Id(), removeReq).Do() + project, d.Get("zone").(string), d.Id(), removeReq).Do() if err != nil { return fmt.Errorf("Error removing instances from InstanceGroup: %s", err) } @@ -257,7 +278,7 @@ func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] InstanceGroup adding instances request: %#v", addReq) addOp, err := config.clientCompute.InstanceGroups.AddInstances( - config.Project, d.Get("zone").(string), d.Id(), addReq).Do() + project, d.Get("zone").(string), d.Id(), addReq).Do() if err != nil { return fmt.Errorf("Error adding instances from InstanceGroup: %s", err) } @@ -281,7 +302,7 @@ func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{} log.Printf("[DEBUG] InstanceGroup updating named ports request: %#v", namedPortsReq) op, err := config.clientCompute.InstanceGroups.SetNamedPorts( - config.Project, d.Get("zone").(string), d.Id(), namedPortsReq).Do() + project, d.Get("zone").(string), d.Id(), namedPortsReq).Do() if err != nil { return fmt.Errorf("Error updating named ports for InstanceGroup: %s", err) } @@ -301,8 +322,13 @@ func resourceComputeInstanceGroupUpdate(d *schema.ResourceData, meta interface{} func resourceComputeInstanceGroupDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) - op, err := config.clientCompute.InstanceGroups.Delete(config.Project, zone, d.Id()).Do() + op, err := config.clientCompute.InstanceGroups.Delete(project, zone, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting InstanceGroup: %s", err) } diff --git a/builtin/providers/google/resource_compute_instance_group_manager.go b/builtin/providers/google/resource_compute_instance_group_manager.go index 3e4e49863b72..970722ae5e1b 100644 --- a/builtin/providers/google/resource_compute_instance_group_manager.go +++ b/builtin/providers/google/resource_compute_instance_group_manager.go @@ -100,6 +100,12 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -119,6 +125,11 @@ func getNamedPorts(nps []interface{}) []*compute.NamedPort { func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Get group size, default to 1 if not given var target_size int64 = 1 if v, ok := d.GetOk("target_size"); ok { @@ -157,7 +168,7 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte log.Printf("[DEBUG] InstanceGroupManager insert request: %#v", manager) op, err := config.clientCompute.InstanceGroupManagers.Insert( - config.Project, d.Get("zone").(string), manager).Do() + project, d.Get("zone").(string), manager).Do() if err != nil { return fmt.Errorf("Error creating InstanceGroupManager: %s", err) } @@ -177,8 +188,13 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + manager, err := config.clientCompute.InstanceGroupManagers.Get( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Instance Group Manager %q because it's gone", d.Get("name").(string)) @@ -203,6 +219,11 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) // If target_pools changes then update @@ -221,7 +242,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte } op, err := config.clientCompute.InstanceGroupManagers.SetTargetPools( - config.Project, d.Get("zone").(string), d.Id(), setTargetPools).Do() + project, d.Get("zone").(string), d.Id(), setTargetPools).Do() if err != nil { return fmt.Errorf("Error updating InstanceGroupManager: %s", err) } @@ -243,7 +264,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte } op, err := config.clientCompute.InstanceGroupManagers.SetInstanceTemplate( - config.Project, d.Get("zone").(string), d.Id(), setInstanceTemplate).Do() + project, d.Get("zone").(string), d.Id(), setInstanceTemplate).Do() if err != nil { return fmt.Errorf("Error updating InstanceGroupManager: %s", err) } @@ -256,7 +277,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte if d.Get("update_strategy").(string) == "RESTART" { managedInstances, err := config.clientCompute.InstanceGroupManagers.ListManagedInstances( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() managedInstanceCount := len(managedInstances.ManagedInstances) instances := make([]string, managedInstanceCount) @@ -269,7 +290,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte } op, err = config.clientCompute.InstanceGroupManagers.RecreateInstances( - config.Project, d.Get("zone").(string), d.Id(), recreateInstances).Do() + project, d.Get("zone").(string), d.Id(), recreateInstances).Do() if err != nil { return fmt.Errorf("Error restarting instance group managers instances: %s", err) @@ -297,7 +318,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte // Make the request: op, err := config.clientCompute.InstanceGroups.SetNamedPorts( - config.Project, d.Get("zone").(string), d.Id(), setNamedPorts).Do() + project, d.Get("zone").(string), d.Id(), setNamedPorts).Do() if err != nil { return fmt.Errorf("Error updating InstanceGroupManager: %s", err) } @@ -318,7 +339,7 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte target_size := int64(v.(int)) op, err := config.clientCompute.InstanceGroupManagers.Resize( - config.Project, d.Get("zone").(string), d.Id(), target_size).Do() + project, d.Get("zone").(string), d.Id(), target_size).Do() if err != nil { return fmt.Errorf("Error updating InstanceGroupManager: %s", err) } @@ -341,8 +362,13 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte func resourceComputeInstanceGroupManagerDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("zone").(string) - op, err := config.clientCompute.InstanceGroupManagers.Delete(config.Project, zone, d.Id()).Do() + op, err := config.clientCompute.InstanceGroupManagers.Delete(project, zone, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting instance group manager: %s", err) } @@ -358,7 +384,7 @@ func resourceComputeInstanceGroupManagerDelete(d *schema.ResourceData, meta inte } instanceGroup, err := config.clientCompute.InstanceGroups.Get( - config.Project, d.Get("zone").(string), d.Id()).Do() + project, d.Get("zone").(string), d.Id()).Do() if err != nil { return fmt.Errorf("Error getting instance group size: %s", err) diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index ea5ed35d657c..5805fd2bb494 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -179,12 +179,6 @@ func resourceComputeInstanceTemplate() *schema.Resource { Deprecated: "Please use `scheduling.on_host_maintenance` instead", }, - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "scheduling": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -262,6 +256,18 @@ func resourceComputeInstanceTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "region": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -341,6 +347,11 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) ([]*compute.Network // Build up the list of networks config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return nil, err + } + networksCount := d.Get("network_interface.#").(int) networkInterfaces := make([]*compute.NetworkInterface, 0, networksCount) for i := 0; i < networksCount; i++ { @@ -372,9 +383,9 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) ([]*compute.Network networkLink = network.SelfLink } else { // lookup subnetwork link using region and subnetwork name - region := d.Get("region").(string) - if region == "" { - region = config.Region + region, err := getRegion(d, config) + if err != nil { + return nil, err } subnetwork, err := config.clientCompute.Subnetworks.Get( project, region, subnetworkName).Do() @@ -409,6 +420,11 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) ([]*compute.Network func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + instanceProperties := &compute.InstanceProperties{} instanceProperties.CanIpForward = d.Get("can_ip_forward").(bool) @@ -503,7 +519,7 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac } op, err := config.clientCompute.InstanceTemplates.Insert( - config.Project, &instanceTemplate).Do() + project, &instanceTemplate).Do() if err != nil { return fmt.Errorf("Error creating instance: %s", err) } @@ -522,8 +538,13 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + instanceTemplate, err := config.clientCompute.InstanceTemplates.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Instance Template %q because it's gone", d.Get("name").(string)) @@ -553,8 +574,13 @@ func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{ func resourceComputeInstanceTemplateDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + op, err := config.clientCompute.InstanceTemplates.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting instance template: %s", err) } diff --git a/builtin/providers/google/resource_compute_network.go b/builtin/providers/google/resource_compute_network.go index 573c72f40855..b3182ab148f0 100644 --- a/builtin/providers/google/resource_compute_network.go +++ b/builtin/providers/google/resource_compute_network.go @@ -56,6 +56,12 @@ func resourceComputeNetwork() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -63,6 +69,11 @@ func resourceComputeNetwork() *schema.Resource { func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // // Possible modes: // - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must not be @@ -91,7 +102,7 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Network insert request: %#v", network) op, err := config.clientCompute.Networks.Insert( - config.Project, network).Do() + project, network).Do() if err != nil { return fmt.Errorf("Error creating network: %s", err) } @@ -110,8 +121,13 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + network, err := config.clientCompute.Networks.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Network %q because it's gone", d.Get("name").(string)) @@ -133,9 +149,14 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error func resourceComputeNetworkDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the network op, err := config.clientCompute.Networks.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting network: %s", err) } diff --git a/builtin/providers/google/resource_compute_project_metadata.go b/builtin/providers/google/resource_compute_project_metadata.go index c2508c8f31ad..39f3ba2b0543 100644 --- a/builtin/providers/google/resource_compute_project_metadata.go +++ b/builtin/providers/google/resource_compute_project_metadata.go @@ -24,6 +24,12 @@ func resourceComputeProjectMetadata() *schema.Resource { Type: schema.TypeMap, Required: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -31,12 +37,17 @@ func resourceComputeProjectMetadata() *schema.Resource { func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + projectID, err := getProject(d, config) + if err != nil { + return err + } + createMD := func() error { // Load project service - log.Printf("[DEBUG] Loading project service: %s", config.Project) - project, err := config.clientCompute.Projects.Get(config.Project).Do() + log.Printf("[DEBUG] Loading project service: %s", projectID) + project, err := config.clientCompute.Projects.Get(projectID).Do() if err != nil { - return fmt.Errorf("Error loading project '%s': %s", config.Project, err) + return fmt.Errorf("Error loading project '%s': %s", projectID, err) } md := project.CommonInstanceMetadata @@ -45,7 +56,7 @@ func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface // Ensure that we aren't overwriting entries that already exist for _, kv := range md.Items { if _, ok := newMDMap[kv.Key]; ok { - return fmt.Errorf("Error, key '%s' already exists in project '%s'", kv.Key, config.Project) + return fmt.Errorf("Error, key '%s' already exists in project '%s'", kv.Key, projectID) } } @@ -58,7 +69,7 @@ func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface }) } - op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(config.Project, md).Do() + op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(projectID, md).Do() if err != nil { return fmt.Errorf("SetCommonInstanceMetadata failed: %s", err) @@ -69,7 +80,7 @@ func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface return computeOperationWaitGlobal(config, op, "SetCommonMetadata") } - err := MetadataRetryWrapper(createMD) + err = MetadataRetryWrapper(createMD) if err != nil { return err } @@ -80,9 +91,14 @@ func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + projectID, err := getProject(d, config) + if err != nil { + return err + } + // Load project service - log.Printf("[DEBUG] Loading project service: %s", config.Project) - project, err := config.clientCompute.Projects.Get(config.Project).Do() + log.Printf("[DEBUG] Loading project service: %s", projectID) + project, err := config.clientCompute.Projects.Get(projectID).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Project Metadata because it's gone") @@ -92,7 +108,7 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{} return nil } - return fmt.Errorf("Error loading project '%s': %s", config.Project, err) + return fmt.Errorf("Error loading project '%s': %s", projectID, err) } md := project.CommonInstanceMetadata @@ -109,22 +125,27 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{} func resourceComputeProjectMetadataUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + projectID, err := getProject(d, config) + if err != nil { + return err + } + if d.HasChange("metadata") { o, n := d.GetChange("metadata") updateMD := func() error { // Load project service - log.Printf("[DEBUG] Loading project service: %s", config.Project) - project, err := config.clientCompute.Projects.Get(config.Project).Do() + log.Printf("[DEBUG] Loading project service: %s", projectID) + project, err := config.clientCompute.Projects.Get(projectID).Do() if err != nil { - return fmt.Errorf("Error loading project '%s': %s", config.Project, err) + return fmt.Errorf("Error loading project '%s': %s", projectID, err) } md := project.CommonInstanceMetadata MetadataUpdate(o.(map[string]interface{}), n.(map[string]interface{}), md) - op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(config.Project, md).Do() + op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(projectID, md).Do() if err != nil { return fmt.Errorf("SetCommonInstanceMetadata failed: %s", err) @@ -152,11 +173,16 @@ func resourceComputeProjectMetadataUpdate(d *schema.ResourceData, meta interface func resourceComputeProjectMetadataDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + projectID, err := getProject(d, config) + if err != nil { + return err + } + // Load project service - log.Printf("[DEBUG] Loading project service: %s", config.Project) - project, err := config.clientCompute.Projects.Get(config.Project).Do() + log.Printf("[DEBUG] Loading project service: %s", projectID) + project, err := config.clientCompute.Projects.Get(projectID).Do() if err != nil { - return fmt.Errorf("Error loading project '%s': %s", config.Project, err) + return fmt.Errorf("Error loading project '%s': %s", projectID, err) } md := project.CommonInstanceMetadata @@ -164,7 +190,7 @@ func resourceComputeProjectMetadataDelete(d *schema.ResourceData, meta interface // Remove all items md.Items = nil - op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(config.Project, md).Do() + op, err := config.clientCompute.Projects.SetCommonInstanceMetadata(projectID, md).Do() log.Printf("[DEBUG] SetCommonMetadata: %d (%s)", op.Id, op.SelfLink) diff --git a/builtin/providers/google/resource_compute_route.go b/builtin/providers/google/resource_compute_route.go index 60337314244e..0e177c895e26 100644 --- a/builtin/providers/google/resource_compute_route.go +++ b/builtin/providers/google/resource_compute_route.go @@ -87,6 +87,12 @@ func resourceComputeRoute() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -94,9 +100,14 @@ func resourceComputeRoute() *schema.Resource { func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Look up the network to attach the route to network, err := config.clientCompute.Networks.Get( - config.Project, d.Get("network").(string)).Do() + project, d.Get("network").(string)).Do() if err != nil { return fmt.Errorf("Error reading network: %s", err) } @@ -115,7 +126,7 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error } if v, ok := d.GetOk("next_hop_instance"); ok { nextInstance, err := config.clientCompute.Instances.Get( - config.Project, + project, d.Get("next_hop_instance_zone").(string), v.(string)).Do() if err != nil { @@ -148,7 +159,7 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Route insert request: %#v", route) op, err := config.clientCompute.Routes.Insert( - config.Project, route).Do() + project, route).Do() if err != nil { return fmt.Errorf("Error creating route: %s", err) } @@ -167,8 +178,13 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + route, err := config.clientCompute.Routes.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Route %q because it's gone", d.Get("name").(string)) @@ -190,9 +206,14 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error { func resourceComputeRouteDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the route op, err := config.clientCompute.Routes.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting route: %s", err) } diff --git a/builtin/providers/google/resource_compute_ssl_certificate.go b/builtin/providers/google/resource_compute_ssl_certificate.go index a80bc2fb2403..8d7a4048b24a 100644 --- a/builtin/providers/google/resource_compute_ssl_certificate.go +++ b/builtin/providers/google/resource_compute_ssl_certificate.go @@ -50,6 +50,12 @@ func resourceComputeSslCertificate() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -57,6 +63,11 @@ func resourceComputeSslCertificate() *schema.Resource { func resourceComputeSslCertificateCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the certificate parameter cert := &compute.SslCertificate{ Name: d.Get("name").(string), @@ -69,7 +80,7 @@ func resourceComputeSslCertificateCreate(d *schema.ResourceData, meta interface{ } op, err := config.clientCompute.SslCertificates.Insert( - config.Project, cert).Do() + project, cert).Do() if err != nil { return fmt.Errorf("Error creating ssl certificate: %s", err) @@ -88,8 +99,13 @@ func resourceComputeSslCertificateCreate(d *schema.ResourceData, meta interface{ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + cert, err := config.clientCompute.SslCertificates.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing SSL Certificate %q because it's gone", d.Get("name").(string)) @@ -111,8 +127,13 @@ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{}) func resourceComputeSslCertificateDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + op, err := config.clientCompute.SslCertificates.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting ssl certificate: %s", err) } diff --git a/builtin/providers/google/resource_compute_subnetwork.go b/builtin/providers/google/resource_compute_subnetwork.go index 61e8caa6e92a..9a0d2b423c7f 100644 --- a/builtin/providers/google/resource_compute_subnetwork.go +++ b/builtin/providers/google/resource_compute_subnetwork.go @@ -4,10 +4,11 @@ import ( "fmt" "log" + "strings" + "github.com/hashicorp/terraform/helper/schema" "google.golang.org/api/compute/v1" "google.golang.org/api/googleapi" - "strings" ) func resourceComputeSubnetwork() *schema.Resource { @@ -56,6 +57,12 @@ func resourceComputeSubnetwork() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -74,6 +81,11 @@ func splitSubnetID(id string) (region string, name string) { func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the subnetwork parameters subnetwork := &compute.Subnetwork{ Name: d.Get("name").(string), @@ -85,7 +97,7 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Subnetwork insert request: %#v", subnetwork) op, err := config.clientCompute.Subnetworks.Insert( - config.Project, region, subnetwork).Do() + project, region, subnetwork).Do() if err != nil { return fmt.Errorf("Error creating subnetwork: %s", err) @@ -109,11 +121,17 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) region := d.Get("region").(string) subnetwork, err := config.clientCompute.Subnetworks.Get( - config.Project, region, name).Do() + project, region, name).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Subnetwork %q because it's gone", name) @@ -134,11 +152,17 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + + project, err := getProject(d, config) + if err != nil { + return err + } + region := d.Get("region").(string) // Delete the subnetwork op, err := config.clientCompute.Subnetworks.Delete( - config.Project, region, d.Get("name").(string)).Do() + project, region, d.Get("name").(string)).Do() if err != nil { return fmt.Errorf("Error deleting subnetwork: %s", err) } diff --git a/builtin/providers/google/resource_compute_target_http_proxy.go b/builtin/providers/google/resource_compute_target_http_proxy.go index 72644fb01740..cec71954d0c7 100644 --- a/builtin/providers/google/resource_compute_target_http_proxy.go +++ b/builtin/providers/google/resource_compute_target_http_proxy.go @@ -44,6 +44,12 @@ func resourceComputeTargetHttpProxy() *schema.Resource { Type: schema.TypeString, Required: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -51,6 +57,11 @@ func resourceComputeTargetHttpProxy() *schema.Resource { func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + proxy := &compute.TargetHttpProxy{ Name: d.Get("name").(string), UrlMap: d.Get("url_map").(string), @@ -62,7 +73,7 @@ func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface log.Printf("[DEBUG] TargetHttpProxy insert request: %#v", proxy) op, err := config.clientCompute.TargetHttpProxies.Insert( - config.Project, proxy).Do() + project, proxy).Do() if err != nil { return fmt.Errorf("Error creating TargetHttpProxy: %s", err) } @@ -80,13 +91,18 @@ func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) if d.HasChange("url_map") { url_map := d.Get("url_map").(string) url_map_ref := &compute.UrlMapReference{UrlMap: url_map} op, err := config.clientCompute.TargetHttpProxies.SetUrlMap( - config.Project, d.Id(), url_map_ref).Do() + project, d.Id(), url_map_ref).Do() if err != nil { return fmt.Errorf("Error updating target: %s", err) } @@ -107,8 +123,13 @@ func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + proxy, err := config.clientCompute.TargetHttpProxies.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Target HTTP Proxy %q because it's gone", d.Get("name").(string)) @@ -130,10 +151,15 @@ func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{} func resourceComputeTargetHttpProxyDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the TargetHttpProxy log.Printf("[DEBUG] TargetHttpProxy delete request") op, err := config.clientCompute.TargetHttpProxies.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting TargetHttpProxy: %s", err) } diff --git a/builtin/providers/google/resource_compute_target_https_proxy.go b/builtin/providers/google/resource_compute_target_https_proxy.go index b30fd1eab880..b505b0227666 100644 --- a/builtin/providers/google/resource_compute_target_https_proxy.go +++ b/builtin/providers/google/resource_compute_target_https_proxy.go @@ -50,6 +50,12 @@ func resourceComputeTargetHttpsProxy() *schema.Resource { Required: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -57,6 +63,11 @@ func resourceComputeTargetHttpsProxy() *schema.Resource { func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + _sslCertificates := d.Get("ssl_certificates").([]interface{}) sslCertificates := make([]string, len(_sslCertificates)) @@ -76,7 +87,7 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] TargetHttpsProxy insert request: %#v", proxy) op, err := config.clientCompute.TargetHttpsProxies.Insert( - config.Project, proxy).Do() + project, proxy).Do() if err != nil { return fmt.Errorf("Error creating TargetHttpsProxy: %s", err) } @@ -94,13 +105,18 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) if d.HasChange("url_map") { url_map := d.Get("url_map").(string) url_map_ref := &compute.UrlMapReference{UrlMap: url_map} op, err := config.clientCompute.TargetHttpsProxies.SetUrlMap( - config.Project, d.Id(), url_map_ref).Do() + project, d.Id(), url_map_ref).Do() if err != nil { return fmt.Errorf("Error updating Target HTTPS proxy URL map: %s", err) } @@ -115,7 +131,7 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac if d.HasChange("ssl_certificates") { proxy, err := config.clientCompute.TargetHttpsProxies.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() _old, _new := d.GetChange("ssl_certificates") _oldCerts := _old.([]interface{}) @@ -161,7 +177,7 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac SslCertificates: sslCertificates, } op, err := config.clientCompute.TargetHttpsProxies.SetSslCertificates( - config.Project, d.Id(), cert_ref).Do() + project, d.Id(), cert_ref).Do() if err != nil { return fmt.Errorf("Error updating Target Https Proxy SSL Certificates: %s", err) } @@ -182,8 +198,13 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + proxy, err := config.clientCompute.TargetHttpsProxies.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Target HTTPS Proxy %q because it's gone", d.Get("name").(string)) @@ -223,10 +244,15 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{ func resourceComputeTargetHttpsProxyDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Delete the TargetHttpsProxy log.Printf("[DEBUG] TargetHttpsProxy delete request") op, err := config.clientCompute.TargetHttpsProxies.Delete( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting TargetHttpsProxy: %s", err) } diff --git a/builtin/providers/google/resource_compute_target_pool.go b/builtin/providers/google/resource_compute_target_pool.go index fa25a1b720d3..8ececab41d57 100644 --- a/builtin/providers/google/resource_compute_target_pool.go +++ b/builtin/providers/google/resource_compute_target_pool.go @@ -72,6 +72,12 @@ func resourceComputeTargetPool() *schema.Resource { Optional: true, ForceNew: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -85,11 +91,11 @@ func convertStringArr(ifaceArr []interface{}) []string { } // Healthchecks need to exist before being referred to from the target pool. -func convertHealthChecks(config *Config, names []string) ([]string, error) { +func convertHealthChecks(config *Config, project string, names []string) ([]string, error) { urls := make([]string, len(names)) for i, name := range names { // Look up the healthcheck - res, err := config.clientCompute.HttpHealthChecks.Get(config.Project, name).Do() + res, err := config.clientCompute.HttpHealthChecks.Get(project, name).Do() if err != nil { return nil, fmt.Errorf("Error reading HealthCheck: %s", err) } @@ -100,7 +106,7 @@ func convertHealthChecks(config *Config, names []string) ([]string, error) { // Instances do not need to exist yet, so we simply generate URLs. // Instances can be full URLS or zone/name -func convertInstances(config *Config, names []string) ([]string, error) { +func convertInstances(config *Config, project string, names []string) ([]string, error) { urls := make([]string, len(names)) for i, name := range names { if strings.HasPrefix(name, "https://www.googleapis.com/compute/v1/") { @@ -112,7 +118,7 @@ func convertInstances(config *Config, names []string) ([]string, error) { } else { urls[i] = fmt.Sprintf( "https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances/%s", - config.Project, splitName[0], splitName[1]) + project, splitName[0], splitName[1]) } } } @@ -121,16 +127,25 @@ func convertInstances(config *Config, names []string) ([]string, error) { func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } hchkUrls, err := convertHealthChecks( - config, convertStringArr(d.Get("health_checks").([]interface{}))) + config, project, convertStringArr(d.Get("health_checks").([]interface{}))) if err != nil { return err } instanceUrls, err := convertInstances( - config, convertStringArr(d.Get("instances").([]interface{}))) + config, project, convertStringArr(d.Get("instances").([]interface{}))) if err != nil { return err } @@ -149,7 +164,7 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] TargetPool insert request: %#v", tpool) op, err := config.clientCompute.TargetPools.Insert( - config.Project, region, tpool).Do() + project, region, tpool).Do() if err != nil { return fmt.Errorf("Error creating TargetPool: %s", err) } @@ -196,7 +211,16 @@ func calcAddRemove(from []string, to []string) ([]string, []string) { func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } d.Partial(true) @@ -205,11 +229,11 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e from_, to_ := d.GetChange("health_checks") from := convertStringArr(from_.([]interface{})) to := convertStringArr(to_.([]interface{})) - fromUrls, err := convertHealthChecks(config, from) + fromUrls, err := convertHealthChecks(config, project, from) if err != nil { return err } - toUrls, err := convertHealthChecks(config, to) + toUrls, err := convertHealthChecks(config, project, to) if err != nil { return err } @@ -222,7 +246,7 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e removeReq.HealthChecks[i] = &compute.HealthCheckReference{HealthCheck: v} } op, err := config.clientCompute.TargetPools.RemoveHealthCheck( - config.Project, region, d.Id(), removeReq).Do() + project, region, d.Id(), removeReq).Do() if err != nil { return fmt.Errorf("Error updating health_check: %s", err) } @@ -238,7 +262,7 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e addReq.HealthChecks[i] = &compute.HealthCheckReference{HealthCheck: v} } op, err = config.clientCompute.TargetPools.AddHealthCheck( - config.Project, region, d.Id(), addReq).Do() + project, region, d.Id(), addReq).Do() if err != nil { return fmt.Errorf("Error updating health_check: %s", err) } @@ -255,11 +279,11 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e from_, to_ := d.GetChange("instances") from := convertStringArr(from_.([]interface{})) to := convertStringArr(to_.([]interface{})) - fromUrls, err := convertInstances(config, from) + fromUrls, err := convertInstances(config, project, from) if err != nil { return err } - toUrls, err := convertInstances(config, to) + toUrls, err := convertInstances(config, project, to) if err != nil { return err } @@ -272,7 +296,7 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e addReq.Instances[i] = &compute.InstanceReference{Instance: v} } op, err := config.clientCompute.TargetPools.AddInstance( - config.Project, region, d.Id(), addReq).Do() + project, region, d.Id(), addReq).Do() if err != nil { return fmt.Errorf("Error updating instances: %s", err) } @@ -288,7 +312,7 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e removeReq.Instances[i] = &compute.InstanceReference{Instance: v} } op, err = config.clientCompute.TargetPools.RemoveInstance( - config.Project, region, d.Id(), removeReq).Do() + project, region, d.Id(), removeReq).Do() if err != nil { return fmt.Errorf("Error updating instances: %s", err) } @@ -305,7 +329,7 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e Target: bpool_name, } op, err := config.clientCompute.TargetPools.SetBackup( - config.Project, region, d.Id(), tref).Do() + project, region, d.Id(), tref).Do() if err != nil { return fmt.Errorf("Error updating backup_pool: %s", err) } @@ -324,10 +348,19 @@ func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) e func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } tpool, err := config.clientCompute.TargetPools.Get( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Target Pool %q because it's gone", d.Get("name").(string)) @@ -347,11 +380,20 @@ func resourceComputeTargetPoolRead(d *schema.ResourceData, meta interface{}) err func resourceComputeTargetPoolDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - region := getOptionalRegion(d, config) + + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } // Delete the TargetPool op, err := config.clientCompute.TargetPools.Delete( - config.Project, region, d.Id()).Do() + project, region, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting TargetPool: %s", err) } diff --git a/builtin/providers/google/resource_compute_url_map.go b/builtin/providers/google/resource_compute_url_map.go index 47a38431fd73..381ad9205575 100644 --- a/builtin/providers/google/resource_compute_url_map.go +++ b/builtin/providers/google/resource_compute_url_map.go @@ -142,6 +142,12 @@ func resourceComputeUrlMap() *schema.Resource { }, }, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -235,6 +241,11 @@ func createUrlMapTest(v interface{}) *compute.UrlMapTest { func resourceComputeUrlMapCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) defaultService := d.Get("default_service").(string) @@ -271,7 +282,7 @@ func resourceComputeUrlMapCreate(d *schema.ResourceData, meta interface{}) error urlMap.Tests[i] = createUrlMapTest(v) } - op, err := config.clientCompute.UrlMaps.Insert(config.Project, urlMap).Do() + op, err := config.clientCompute.UrlMaps.Insert(project, urlMap).Do() if err != nil { return fmt.Errorf("Error, failed to insert Url Map %s: %s", name, err) @@ -289,9 +300,14 @@ func resourceComputeUrlMapCreate(d *schema.ResourceData, meta interface{}) error func resourceComputeUrlMapRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - urlMap, err := config.clientCompute.UrlMaps.Get(config.Project, name).Do() + urlMap, err := config.clientCompute.UrlMaps.Get(project, name).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { @@ -425,8 +441,13 @@ func resourceComputeUrlMapRead(d *schema.ResourceData, meta interface{}) error { func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - urlMap, err := config.clientCompute.UrlMaps.Get(config.Project, name).Do() + urlMap, err := config.clientCompute.UrlMaps.Get(project, name).Do() if err != nil { return fmt.Errorf("Error, failed to get Url Map %s: %s", name, err) } @@ -624,7 +645,7 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error urlMap.Tests = newTests } - op, err := config.clientCompute.UrlMaps.Update(config.Project, urlMap.Name, urlMap).Do() + op, err := config.clientCompute.UrlMaps.Update(project, urlMap.Name, urlMap).Do() if err != nil { return fmt.Errorf("Error, failed to update Url Map %s: %s", name, err) @@ -641,9 +662,15 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error func resourceComputeUrlMapDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - op, err := config.clientCompute.UrlMaps.Delete(config.Project, name).Do() + op, err := config.clientCompute.UrlMaps.Delete(project, name).Do() if err != nil { return fmt.Errorf("Error, failed to delete Url Map %s: %s", name, err) diff --git a/builtin/providers/google/resource_compute_vpn_gateway.go b/builtin/providers/google/resource_compute_vpn_gateway.go index 562e3dfac45a..1e7de64b985a 100644 --- a/builtin/providers/google/resource_compute_vpn_gateway.go +++ b/builtin/providers/google/resource_compute_vpn_gateway.go @@ -34,14 +34,19 @@ func resourceComputeVpnGateway() *schema.Resource { Required: true, ForceNew: true, }, + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, "region": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, - "self_link": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, }, } @@ -50,10 +55,18 @@ func resourceComputeVpnGateway() *schema.Resource { func resourceComputeVpnGatewayCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) network := d.Get("network").(string) - region := getOptionalRegion(d, config) - project := config.Project vpnGatewaysService := compute.NewTargetVpnGatewaysService(config.clientCompute) @@ -82,9 +95,17 @@ func resourceComputeVpnGatewayCreate(d *schema.ResourceData, meta interface{}) e func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - region := getOptionalRegion(d, config) - project := config.Project vpnGatewaysService := compute.NewTargetVpnGatewaysService(config.clientCompute) vpnGateway, err := vpnGatewaysService.Get(project, region, name).Do() @@ -110,9 +131,17 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err func resourceComputeVpnGatewayDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - region := getOptionalRegion(d, config) - project := config.Project vpnGatewaysService := compute.NewTargetVpnGatewaysService(config.clientCompute) diff --git a/builtin/providers/google/resource_compute_vpn_tunnel.go b/builtin/providers/google/resource_compute_vpn_tunnel.go index 2788dda8d680..4e94e4f0587d 100644 --- a/builtin/providers/google/resource_compute_vpn_tunnel.go +++ b/builtin/providers/google/resource_compute_vpn_tunnel.go @@ -31,11 +31,6 @@ func resourceComputeVpnTunnel() *schema.Resource { Optional: true, ForceNew: true, }, - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, "peer_ip": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -73,6 +68,16 @@ func resourceComputeVpnTunnel() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "region": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -80,13 +85,21 @@ func resourceComputeVpnTunnel() *schema.Resource { func resourceComputeVpnTunnelCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - region := getOptionalRegion(d, config) peerIp := d.Get("peer_ip").(string) sharedSecret := d.Get("shared_secret").(string) targetVpnGateway := d.Get("target_vpn_gateway").(string) ikeVersion := d.Get("ike_version").(int) - project := config.Project if ikeVersion < 1 || ikeVersion > 2 { return fmt.Errorf("Only IKE version 1 or 2 supported, not %d", ikeVersion) @@ -132,9 +145,17 @@ func resourceComputeVpnTunnelCreate(d *schema.ResourceData, meta interface{}) er func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - region := getOptionalRegion(d, config) - project := config.Project vpnTunnelsService := compute.NewVpnTunnelsService(config.clientCompute) @@ -162,9 +183,17 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro func resourceComputeVpnTunnelDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) - region := getOptionalRegion(d, config) - project := config.Project vpnTunnelsService := compute.NewVpnTunnelsService(config.clientCompute) diff --git a/builtin/providers/google/resource_container_cluster.go b/builtin/providers/google/resource_container_cluster.go index 841644015b55..08dddaf27da8 100644 --- a/builtin/providers/google/resource_container_cluster.go +++ b/builtin/providers/google/resource_container_cluster.go @@ -195,6 +195,12 @@ func resourceContainerCluster() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -202,6 +208,11 @@ func resourceContainerCluster() *schema.Resource { func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zoneName := d.Get("zone").(string) clusterName := d.Get("name").(string) @@ -273,7 +284,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er } op, err := config.clientContainer.Projects.Zones.Clusters.Create( - config.Project, zoneName, req).Do() + project, zoneName, req).Do() if err != nil { return err } @@ -286,7 +297,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er MinTimeout: 3 * time.Second, Refresh: func() (interface{}, string, error) { resp, err := config.clientContainer.Projects.Zones.Operations.Get( - config.Project, zoneName, op.Name).Do() + project, zoneName, op.Name).Do() log.Printf("[DEBUG] Progress of creating GKE cluster %s: %s", clusterName, resp.Status) return resp, resp.Status, err @@ -308,10 +319,15 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zoneName := d.Get("zone").(string) cluster, err := config.clientContainer.Projects.Zones.Clusters.Get( - config.Project, zoneName, d.Get("name").(string)).Do() + project, zoneName, d.Get("name").(string)).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing Container Cluster %q because it's gone", d.Get("name").(string)) @@ -355,6 +371,11 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zoneName := d.Get("zone").(string) clusterName := d.Get("name").(string) desiredNodeVersion := d.Get("node_version").(string) @@ -365,7 +386,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er }, } op, err := config.clientContainer.Projects.Zones.Clusters.Update( - config.Project, zoneName, clusterName, req).Do() + project, zoneName, clusterName, req).Do() if err != nil { return err } @@ -379,7 +400,7 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er Refresh: func() (interface{}, string, error) { log.Printf("[DEBUG] Checking if GKE cluster %s is updated", clusterName) resp, err := config.clientContainer.Projects.Zones.Operations.Get( - config.Project, zoneName, op.Name).Do() + project, zoneName, op.Name).Do() log.Printf("[DEBUG] Progress of updating GKE cluster %s: %s", clusterName, resp.Status) return resp, resp.Status, err @@ -400,12 +421,17 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zoneName := d.Get("zone").(string) clusterName := d.Get("name").(string) log.Printf("[DEBUG] Deleting GKE cluster %s", d.Get("name").(string)) op, err := config.clientContainer.Projects.Zones.Clusters.Delete( - config.Project, zoneName, clusterName).Do() + project, zoneName, clusterName).Do() if err != nil { return err } @@ -419,7 +445,7 @@ func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) er Refresh: func() (interface{}, string, error) { log.Printf("[DEBUG] Checking if GKE cluster %s is deleted", clusterName) resp, err := config.clientContainer.Projects.Zones.Operations.Get( - config.Project, zoneName, op.Name).Do() + project, zoneName, op.Name).Do() log.Printf("[DEBUG] Progress of deleting GKE cluster %s: %s", clusterName, resp.Status) return resp, resp.Status, err diff --git a/builtin/providers/google/resource_dns_managed_zone.go b/builtin/providers/google/resource_dns_managed_zone.go index 0ef813ef2d11..913353593460 100644 --- a/builtin/providers/google/resource_dns_managed_zone.go +++ b/builtin/providers/google/resource_dns_managed_zone.go @@ -44,6 +44,12 @@ func resourceDnsManagedZone() *schema.Resource { }, // Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -51,6 +57,11 @@ func resourceDnsManagedZone() *schema.Resource { func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Build the parameter zone := &dns.ManagedZone{ Name: d.Get("name").(string), @@ -65,7 +76,7 @@ func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] DNS ManagedZone create request: %#v", zone) - zone, err := config.clientDns.ManagedZones.Create(config.Project, zone).Do() + zone, err = config.clientDns.ManagedZones.Create(project, zone).Do() if err != nil { return fmt.Errorf("Error creating DNS ManagedZone: %s", err) } @@ -78,8 +89,13 @@ func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro func resourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone, err := config.clientDns.ManagedZones.Get( - config.Project, d.Id()).Do() + project, d.Id()).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing DNS Managed Zone %q because it's gone", d.Get("name").(string)) @@ -100,7 +116,12 @@ func resourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error func resourceDnsManagedZoneDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - err := config.clientDns.ManagedZones.Delete(config.Project, d.Id()).Do() + project, err := getProject(d, config) + if err != nil { + return err + } + + err = config.clientDns.ManagedZones.Delete(project, d.Id()).Do() if err != nil { return fmt.Errorf("Error deleting DNS ManagedZone: %s", err) } diff --git a/builtin/providers/google/resource_dns_record_set.go b/builtin/providers/google/resource_dns_record_set.go index 49b1fce71b26..5f0b7a51ea97 100644 --- a/builtin/providers/google/resource_dns_record_set.go +++ b/builtin/providers/google/resource_dns_record_set.go @@ -49,6 +49,12 @@ func resourceDnsRecordSet() *schema.Resource { Type: schema.TypeString, }, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -56,6 +62,11 @@ func resourceDnsRecordSet() *schema.Resource { func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("managed_zone").(string) rrdatasCount := d.Get("rrdatas.#").(int) @@ -78,7 +89,7 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] DNS Record create request: %#v", chg) - chg, err := config.clientDns.Changes.Create(config.Project, zone, chg).Do() + chg, err = config.clientDns.Changes.Create(project, zone, chg).Do() if err != nil { return fmt.Errorf("Error creating DNS RecordSet: %s", err) } @@ -88,7 +99,7 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error w := &DnsChangeWaiter{ Service: config.clientDns, Change: chg, - Project: config.Project, + Project: project, ManagedZone: zone, } state := w.Conf() @@ -106,6 +117,11 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("managed_zone").(string) // name and type are effectively the 'key' @@ -113,7 +129,7 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { dnsType := d.Get("type").(string) resp, err := config.clientDns.ResourceRecordSets.List( - config.Project, zone).Name(name).Type(dnsType).Do() + project, zone).Name(name).Type(dnsType).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { log.Printf("[WARN] Removing DNS Record Set %q because it's gone", d.Get("name").(string)) @@ -144,6 +160,11 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + zone := d.Get("managed_zone").(string) rrdatasCount := d.Get("rrdatas.#").(int) @@ -165,7 +186,7 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error chg.Deletions[0].Rrdatas[i] = d.Get(rrdata).(string) } log.Printf("[DEBUG] DNS Record delete request: %#v", chg) - chg, err := config.clientDns.Changes.Create(config.Project, zone, chg).Do() + chg, err = config.clientDns.Changes.Create(project, zone, chg).Do() if err != nil { return fmt.Errorf("Error deleting DNS RecordSet: %s", err) } @@ -173,7 +194,7 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error w := &DnsChangeWaiter{ Service: config.clientDns, Change: chg, - Project: config.Project, + Project: project, ManagedZone: zone, } state := w.Conf() diff --git a/builtin/providers/google/resource_pubsub_subscription.go b/builtin/providers/google/resource_pubsub_subscription.go index c006818f664b..19f3f38e7662 100644 --- a/builtin/providers/google/resource_pubsub_subscription.go +++ b/builtin/providers/google/resource_pubsub_subscription.go @@ -53,6 +53,12 @@ func resourcePubsubSubscription() *schema.Resource { Required: true, ForceNew: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -68,8 +74,13 @@ func cleanAdditionalArgs(args map[string]interface{}) map[string]string { func resourcePubsubSubscriptionCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - name := fmt.Sprintf("projects/%s/subscriptions/%s", config.Project, d.Get("name").(string)) - computed_topic_name := fmt.Sprintf("projects/%s/topics/%s", config.Project, d.Get("topic").(string)) + project, err := getProject(d, config) + if err != nil { + return err + } + + name := fmt.Sprintf("projects/%s/subscriptions/%s", project, d.Get("name").(string)) + computed_topic_name := fmt.Sprintf("projects/%s/topics/%s", project, d.Get("topic").(string)) // process optional parameters var ackDeadlineSeconds int64 diff --git a/builtin/providers/google/resource_pubsub_topic.go b/builtin/providers/google/resource_pubsub_topic.go index 9d6a6a87976e..84932e4e9623 100644 --- a/builtin/providers/google/resource_pubsub_topic.go +++ b/builtin/providers/google/resource_pubsub_topic.go @@ -19,6 +19,12 @@ func resourcePubsubTopic() *schema.Resource { Required: true, ForceNew: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -26,7 +32,12 @@ func resourcePubsubTopic() *schema.Resource { func resourcePubsubTopicCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - name := fmt.Sprintf("projects/%s/topics/%s", config.Project, d.Get("name").(string)) + project, err := getProject(d, config) + if err != nil { + return err + } + + name := fmt.Sprintf("projects/%s/topics/%s", project, d.Get("name").(string)) topic := &pubsub.Topic{} call := config.clientPubsub.Projects.Topics.Create(name, topic) diff --git a/builtin/providers/google/resource_sql_database.go b/builtin/providers/google/resource_sql_database.go index f66d3c58456c..8ef245b1dfc1 100644 --- a/builtin/providers/google/resource_sql_database.go +++ b/builtin/providers/google/resource_sql_database.go @@ -31,6 +31,11 @@ func resourceSqlDatabase() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -38,9 +43,13 @@ func resourceSqlDatabase() *schema.Resource { func resourceSqlDatabaseCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + database_name := d.Get("name").(string) instance_name := d.Get("instance").(string) - project := config.Project db := &sqladmin.Database{ Name: database_name, @@ -69,9 +78,13 @@ func resourceSqlDatabaseCreate(d *schema.ResourceData, meta interface{}) error { func resourceSqlDatabaseRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + database_name := d.Get("name").(string) instance_name := d.Get("instance").(string) - project := config.Project db, err := config.clientSqlAdmin.Databases.Get(project, instance_name, database_name).Do() @@ -99,9 +112,13 @@ func resourceSqlDatabaseRead(d *schema.ResourceData, meta interface{}) error { func resourceSqlDatabaseDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + database_name := d.Get("name").(string) instance_name := d.Get("instance").(string) - project := config.Project op, err := config.clientSqlAdmin.Databases.Delete(project, instance_name, database_name).Do() diff --git a/builtin/providers/google/resource_sql_database_instance.go b/builtin/providers/google/resource_sql_database_instance.go index e4d1c3087f83..a8945caad3b8 100644 --- a/builtin/providers/google/resource_sql_database_instance.go +++ b/builtin/providers/google/resource_sql_database_instance.go @@ -245,6 +245,12 @@ func resourceSqlDatabaseInstance() *schema.Resource { }, }, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -252,6 +258,11 @@ func resourceSqlDatabaseInstance() *schema.Resource { func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + region := d.Get("region").(string) databaseVersion := d.Get("database_version").(string) @@ -468,7 +479,7 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{}) instance.MasterInstanceName = v.(string) } - op, err := config.clientSqlAdmin.Instances.Insert(config.Project, instance).Do() + op, err := config.clientSqlAdmin.Instances.Insert(project, instance).Do() if err != nil { if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 409 { return fmt.Errorf("Error, the name %s is unavailable because it was used recently", instance.Name) @@ -488,7 +499,12 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{}) func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - instance, err := config.clientSqlAdmin.Instances.Get(config.Project, + project, err := getProject(d, config) + if err != nil { + return err + } + + instance, err := config.clientSqlAdmin.Instances.Get(project, d.Get("name").(string)).Do() if err != nil { @@ -742,9 +758,15 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + + project, err := getProject(d, config) + if err != nil { + return err + } + d.Partial(true) - instance, err := config.clientSqlAdmin.Instances.Get(config.Project, + instance, err := config.clientSqlAdmin.Instances.Get(project, d.Get("name").(string)).Do() if err != nil { @@ -963,7 +985,7 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) d.Partial(false) - op, err := config.clientSqlAdmin.Instances.Update(config.Project, instance.Name, instance).Do() + op, err := config.clientSqlAdmin.Instances.Update(project, instance.Name, instance).Do() if err != nil { return fmt.Errorf("Error, failed to update instance %s: %s", instance.Name, err) } @@ -979,7 +1001,12 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) func resourceSqlDatabaseInstanceDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - op, err := config.clientSqlAdmin.Instances.Delete(config.Project, d.Get("name").(string)).Do() + project, err := getProject(d, config) + if err != nil { + return err + } + + op, err := config.clientSqlAdmin.Instances.Delete(project, d.Get("name").(string)).Do() if err != nil { return fmt.Errorf("Error, failed to delete instance %s: %s", d.Get("name").(string), err) diff --git a/builtin/providers/google/resource_sql_user.go b/builtin/providers/google/resource_sql_user.go index 06e76becc937..b787ed040a53 100644 --- a/builtin/providers/google/resource_sql_user.go +++ b/builtin/providers/google/resource_sql_user.go @@ -40,6 +40,12 @@ func resourceSqlUser() *schema.Resource { Required: true, ForceNew: true, }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -47,11 +53,15 @@ func resourceSqlUser() *schema.Resource { func resourceSqlUserCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) instance := d.Get("instance").(string) password := d.Get("password").(string) host := d.Get("host").(string) - project := config.Project user := &sqladmin.User{ Name: name, @@ -81,9 +91,13 @@ func resourceSqlUserCreate(d *schema.ResourceData, meta interface{}) error { func resourceSqlUserRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) instance := d.Get("instance").(string) - project := config.Project users, err := config.clientSqlAdmin.Users.List(project, instance).Do() @@ -122,11 +136,15 @@ func resourceSqlUserUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) if d.HasChange("password") { + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) instance := d.Get("instance").(string) host := d.Get("host").(string) password := d.Get("password").(string) - project := config.Project user := &sqladmin.User{ Name: name, @@ -159,10 +177,14 @@ func resourceSqlUserUpdate(d *schema.ResourceData, meta interface{}) error { func resourceSqlUserDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + name := d.Get("name").(string) instance := d.Get("instance").(string) host := d.Get("host").(string) - project := config.Project op, err := config.clientSqlAdmin.Users.Delete(project, instance, host, name).Do() diff --git a/builtin/providers/google/resource_storage_bucket.go b/builtin/providers/google/resource_storage_bucket.go index c4e64244fb9b..105430765f27 100644 --- a/builtin/providers/google/resource_storage_bucket.go +++ b/builtin/providers/google/resource_storage_bucket.go @@ -61,6 +61,11 @@ func resourceStorageBucket() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -68,6 +73,11 @@ func resourceStorageBucket() *schema.Resource { func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + project, err := getProject(d, config) + if err != nil { + return err + } + // Get the bucket and acl bucket := d.Get("name").(string) location := d.Get("location").(string) @@ -95,7 +105,7 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error } } - call := config.clientStorage.Buckets.Insert(config.Project, sb) + call := config.clientStorage.Buckets.Insert(project, sb) if v, ok := d.GetOk("predefined_acl"); ok { call = call.PredefinedAcl(v.(string)) } From 29b073158f30b58d3c662e75f2831b104e8b35b4 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 10 Apr 2016 17:34:15 -0400 Subject: [PATCH 046/665] Update documentation to include new "project" attribute This commit also normalizes the format we display attributes. --- .../google/resource_compute_address.go | 10 +- .../google/resource_compute_autoscaler.go | 22 +- .../resource_compute_backend_service.go | 76 +++---- .../providers/google/resource_compute_disk.go | 18 +- .../google/resource_compute_firewall.go | 32 +-- .../resource_compute_forwarding_rule.go | 36 +-- .../google/resource_compute_global_address.go | 10 +- ...resource_compute_global_forwarding_rule.go | 34 +-- .../resource_compute_http_health_check.go | 24 +- .../resource_compute_https_health_check.go | 24 +- .../google/resource_compute_instance.go | 148 ++++++------- .../google/resource_compute_instance_group.go | 34 +-- ...resource_compute_instance_group_manager.go | 53 +++-- .../resource_compute_instance_template.go | 122 +++++------ .../google/resource_compute_network.go | 26 +-- .../google/resource_compute_route.go | 32 +-- .../resource_compute_ssl_certificate.go | 20 +- .../google/resource_compute_subnetwork.go | 41 ++-- .../resource_compute_target_http_proxy.go | 20 +- .../resource_compute_target_https_proxy.go | 22 +- .../google/resource_compute_target_pool.go | 24 +- .../google/resource_compute_url_map.go | 28 +-- .../google/resource_compute_vpn_gateway.go | 23 +- .../google/resource_compute_vpn_tunnel.go | 38 ++-- .../google/resource_container_cluster.go | 120 +++++----- .../google/resource_dns_managed_zone.go | 4 +- .../google/resource_dns_record_set.go | 18 +- .../google/resource_pubsub_subscription.go | 24 +- .../providers/google/resource_sql_database.go | 11 +- .../google/resource_sql_database_instance.go | 55 +++-- builtin/providers/google/resource_sql_user.go | 10 +- .../google/resource_storage_bucket.go | 36 +-- .../google/resource_storage_bucket_acl.go | 11 +- .../google/resource_storage_bucket_object.go | 30 +-- .../google/resource_storage_object_acl.go | 13 +- .../docs/providers/google/index.html.markdown | 8 +- .../google/r/compute_address.html.markdown | 18 +- .../google/r/compute_autoscaler.html.markdown | 102 +++++---- .../r/compute_backend_service.html.markdown | 130 ++++++----- .../google/r/compute_disk.html.markdown | 35 +-- .../google/r/compute_firewall.html.markdown | 43 ++-- .../r/compute_forwarding_rule.html.markdown | 42 ++-- .../r/compute_global_address.html.markdown | 16 +- ...mpute_global_forwarding_rule.html.markdown | 93 ++++---- .../r/compute_http_health_check.html.markdown | 39 ++-- .../compute_https_health_check.html.markdown | 28 ++- .../google/r/compute_instance.html.markdown | 167 +++++++------- .../r/compute_instance_group.html.markdown | 84 ++++--- ...mpute_instance_group_manager.html.markdown | 90 ++++---- .../r/compute_instance_template.html.markdown | 206 +++++++++--------- .../google/r/compute_network.html.markdown | 42 ++-- .../r/compute_project_metadata.html.markdown | 25 ++- .../google/r/compute_route.html.markdown | 57 +++-- .../r/compute_ssl_certificate.html.markdown | 32 ++- .../google/r/compute_subnetwork.html.markdown | 33 +-- .../r/compute_target_http_proxy.html.markdown | 80 ++++--- .../compute_target_https_proxy.html.markdown | 99 +++++---- .../r/compute_target_pool.html.markdown | 56 +++-- .../google/r/compute_url_map.html.markdown | 142 ++++++------ .../r/compute_vpn_gateway.html.markdown | 101 +++++---- .../google/r/compute_vpn_tunnel.html.markdown | 123 ++++++----- .../google/r/container_cluster.html.markdown | 131 +++++++---- .../google/r/dns_managed_zone.markdown | 24 +- .../google/r/dns_record_set.markdown | 59 ++--- .../r/pubsub_subscription.html.markdown | 34 ++- .../google/r/pubsub_topic.html.markdown | 15 +- .../google/r/sql_database.html.markdown | 23 +- .../r/sql_database_instance.html.markdown | 121 +++++----- .../providers/google/r/sql_user.html.markdown | 38 ++-- .../google/r/storage_bucket.html.markdown | 43 ++-- .../google/r/storage_bucket_acl.html.markdown | 27 ++- .../r/storage_bucket_object.html.markdown | 29 +-- .../google/r/storage_object_acl.html.markdown | 33 ++- 73 files changed, 2059 insertions(+), 1658 deletions(-) diff --git a/builtin/providers/google/resource_compute_address.go b/builtin/providers/google/resource_compute_address.go index 4567e4280b9c..427f24610beb 100644 --- a/builtin/providers/google/resource_compute_address.go +++ b/builtin/providers/google/resource_compute_address.go @@ -27,9 +27,10 @@ func resourceComputeAddress() *schema.Resource { Computed: true, }, - "self_link": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, "region": &schema.Schema{ @@ -38,10 +39,9 @@ func resourceComputeAddress() *schema.Resource { ForceNew: true, }, - "project": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_compute_autoscaler.go b/builtin/providers/google/resource_compute_autoscaler.go index 7fd8819de8ce..cb6834b57940 100644 --- a/builtin/providers/google/resource_compute_autoscaler.go +++ b/builtin/providers/google/resource_compute_autoscaler.go @@ -23,14 +23,15 @@ func resourceComputeAutoscaler() *schema.Resource { Required: true, }, - "description": &schema.Schema{ + "target": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, }, - "target": &schema.Schema{ + "zone": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, }, "autoscaling_policy": &schema.Schema{ @@ -105,15 +106,9 @@ func resourceComputeAutoscaler() *schema.Resource { }, }, - "zone": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "self_link": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, }, "project": &schema.Schema{ @@ -121,6 +116,11 @@ func resourceComputeAutoscaler() *schema.Resource { Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_backend_service.go b/builtin/providers/google/resource_compute_backend_service.go index f0402478177c..94bc23439f7a 100644 --- a/builtin/providers/google/resource_compute_backend_service.go +++ b/builtin/providers/google/resource_compute_backend_service.go @@ -20,10 +20,36 @@ func resourceComputeBackendService() *schema.Resource { Delete: resourceComputeBackendServiceDelete, Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + re := `^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$` + if !regexp.MustCompile(re).MatchString(value) { + errors = append(errors, fmt.Errorf( + "%q (%q) doesn't match regexp %q", k, value, re)) + } + return + }, + }, + + "health_checks": &schema.Schema{ + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Required: true, + Set: schema.HashString, + }, + "backend": &schema.Schema{ Type: schema.TypeSet, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "group": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, "balancing_mode": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -38,10 +64,6 @@ func resourceComputeBackendService() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "group": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, "max_rate": &schema.Schema{ Type: schema.TypeInt, Optional: true, @@ -66,32 +88,9 @@ func resourceComputeBackendService() *schema.Resource { Optional: true, }, - "region": &schema.Schema{ - Type: schema.TypeString, - ForceNew: true, - Optional: true, - }, - - "health_checks": &schema.Schema{ - Type: schema.TypeSet, - Elem: &schema.Schema{Type: schema.TypeString}, - Required: true, - Set: schema.HashString, - }, - - "name": &schema.Schema{ + "fingerprint": &schema.Schema{ Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - re := `^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$` - if !regexp.MustCompile(re).MatchString(value) { - errors = append(errors, fmt.Errorf( - "%q (%q) doesn't match regexp %q", k, value, re)) - } - return - }, + Computed: true, }, "port_name": &schema.Schema{ @@ -100,21 +99,22 @@ func resourceComputeBackendService() *schema.Resource { Computed: true, }, - "protocol": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, Optional: true, - Computed: true, + ForceNew: true, }, - "timeout_sec": &schema.Schema{ - Type: schema.TypeInt, + "protocol": &schema.Schema{ + Type: schema.TypeString, Optional: true, Computed: true, }, - "fingerprint": &schema.Schema{ + "region": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, "self_link": &schema.Schema{ @@ -122,10 +122,10 @@ func resourceComputeBackendService() *schema.Resource { Computed: true, }, - "project": &schema.Schema{ - Type: schema.TypeString, + "timeout_sec": &schema.Schema{ + Type: schema.TypeInt, Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_compute_disk.go b/builtin/providers/google/resource_compute_disk.go index 62d0ea3e1c2b..b307505f8b64 100644 --- a/builtin/providers/google/resource_compute_disk.go +++ b/builtin/providers/google/resource_compute_disk.go @@ -34,16 +34,21 @@ func resourceComputeDisk() *schema.Resource { ForceNew: true, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "size": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, }, - "type": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, "snapshot": &schema.Schema{ @@ -52,12 +57,7 @@ func resourceComputeDisk() *schema.Resource { ForceNew: true, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "project": &schema.Schema{ + "type": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, diff --git a/builtin/providers/google/resource_compute_firewall.go b/builtin/providers/google/resource_compute_firewall.go index 1676b22a6208..a4776c34dfb3 100644 --- a/builtin/providers/google/resource_compute_firewall.go +++ b/builtin/providers/google/resource_compute_firewall.go @@ -26,11 +26,6 @@ func resourceComputeFirewall() *schema.Resource { ForceNew: true, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - "network": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -58,6 +53,22 @@ func resourceComputeFirewall() *schema.Resource { Set: resourceComputeFirewallAllowHash, }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ranges": &schema.Schema{ Type: schema.TypeSet, Optional: true, @@ -78,17 +89,6 @@ func resourceComputeFirewall() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, - - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_forwarding_rule.go b/builtin/providers/google/resource_compute_forwarding_rule.go index 0f71627376f4..af6b267d1187 100644 --- a/builtin/providers/google/resource_compute_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_forwarding_rule.go @@ -17,18 +17,16 @@ func resourceComputeForwardingRule() *schema.Resource { Update: resourceComputeForwardingRuleUpdate, Schema: map[string]*schema.Schema{ - "ip_address": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, - Computed: true, }, - "ip_protocol": &schema.Schema{ + "target": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Required: true, + ForceNew: false, }, "description": &schema.Schema{ @@ -37,27 +35,30 @@ func resourceComputeForwardingRule() *schema.Resource { ForceNew: true, }, - "name": &schema.Schema{ + "ip_address": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, + Computed: true, }, - "port_range": &schema.Schema{ + "ip_protocol": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, - "self_link": &schema.Schema{ + "port_range": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, - "target": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Required: true, - ForceNew: false, + Optional: true, + ForceNew: true, }, "region": &schema.Schema{ @@ -66,10 +67,9 @@ func resourceComputeForwardingRule() *schema.Resource { ForceNew: true, }, - "project": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_compute_global_address.go b/builtin/providers/google/resource_compute_global_address.go index 5549022393a5..6c2da4fc75c9 100644 --- a/builtin/providers/google/resource_compute_global_address.go +++ b/builtin/providers/google/resource_compute_global_address.go @@ -27,16 +27,16 @@ func resourceComputeGlobalAddress() *schema.Resource { Computed: true, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "project": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_global_forwarding_rule.go b/builtin/providers/google/resource_compute_global_forwarding_rule.go index 5c41675e1833..e098a993d5fe 100644 --- a/builtin/providers/google/resource_compute_global_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_global_forwarding_rule.go @@ -17,18 +17,15 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { Delete: resourceComputeGlobalForwardingRuleDelete, Schema: map[string]*schema.Schema{ - "ip_address": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, - Computed: true, }, - "ip_protocol": &schema.Schema{ + "target": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Required: true, }, "description": &schema.Schema{ @@ -37,26 +34,30 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { ForceNew: true, }, - "name": &schema.Schema{ + "ip_address": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, + Computed: true, }, - "port_range": &schema.Schema{ + "ip_protocol": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, - "self_link": &schema.Schema{ + "port_range": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, - "target": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + ForceNew: true, }, "region": &schema.Schema{ @@ -66,10 +67,9 @@ func resourceComputeGlobalForwardingRule() *schema.Resource { Deprecated: "Please remove this attribute (it was never used)", }, - "project": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_compute_http_health_check.go b/builtin/providers/google/resource_compute_http_health_check.go index 0d8eaed0b9bf..b9114273a6cc 100644 --- a/builtin/providers/google/resource_compute_http_health_check.go +++ b/builtin/providers/google/resource_compute_http_health_check.go @@ -17,6 +17,12 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Update: resourceComputeHttpHealthCheckUpdate, Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "check_interval_sec": &schema.Schema{ Type: schema.TypeInt, Optional: true, @@ -39,18 +45,18 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Optional: true, }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "port": &schema.Schema{ Type: schema.TypeInt, Optional: true, Default: 80, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "request_path": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -73,12 +79,6 @@ func resourceComputeHttpHealthCheck() *schema.Resource { Optional: true, Default: 2, }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_https_health_check.go b/builtin/providers/google/resource_compute_https_health_check.go index 64b50483dff3..a52fa186c8a3 100644 --- a/builtin/providers/google/resource_compute_https_health_check.go +++ b/builtin/providers/google/resource_compute_https_health_check.go @@ -17,6 +17,12 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { Update: resourceComputeHttpsHealthCheckUpdate, Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "check_interval_sec": &schema.Schema{ Type: schema.TypeInt, Optional: true, @@ -39,18 +45,18 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { Optional: true, }, - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "port": &schema.Schema{ Type: schema.TypeInt, Optional: true, Default: 443, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "request_path": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -73,12 +79,6 @@ func resourceComputeHttpsHealthCheck() *schema.Resource { Optional: true, Default: 2, }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index a50e1c105581..bc0c0d244d86 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -26,30 +26,6 @@ func resourceComputeInstance() *schema.Resource { MigrateState: resourceComputeInstanceMigrateState, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "machine_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "zone": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "disk": &schema.Schema{ Type: schema.TypeList, Required: true, @@ -103,6 +79,55 @@ func resourceComputeInstance() *schema.Resource { }, }, + "machine_type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "zone": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "can_ip_forward": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "metadata": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Elem: schema.TypeString, + ValidateFunc: validateInstanceMetadata, + }, + + "metadata_startup_script": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "metadata_fingerprint": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "network_interface": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -189,24 +214,38 @@ func resourceComputeInstance() *schema.Resource { }, }, - "can_ip_forward": &schema.Schema{ - Type: schema.TypeBool, + "project": &schema.Schema{ + Type: schema.TypeString, Optional: true, - Default: false, ForceNew: true, }, - "metadata_startup_script": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, - "metadata": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Elem: schema.TypeString, - ValidateFunc: validateInstanceMetadata, + "scheduling": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "on_host_maintenance": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + + "automatic_restart": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + }, + + "preemptible": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + }, + }, + }, }, "service_account": &schema.Schema{ @@ -237,29 +276,6 @@ func resourceComputeInstance() *schema.Resource { }, }, - "scheduling": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "on_host_maintenance": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, - - "automatic_restart": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - }, - - "preemptible": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - }, - }, - }, - }, - "tags": &schema.Schema{ Type: schema.TypeSet, Optional: true, @@ -267,26 +283,10 @@ func resourceComputeInstance() *schema.Resource { Set: schema.HashString, }, - "metadata_fingerprint": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "tags_fingerprint": &schema.Schema{ Type: schema.TypeString, Computed: true, }, - - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_instance_group.go b/builtin/providers/google/resource_compute_instance_group.go index cd6d31088ccd..4bbbc4e4513e 100644 --- a/builtin/providers/google/resource_compute_instance_group.go +++ b/builtin/providers/google/resource_compute_instance_group.go @@ -25,12 +25,24 @@ func resourceComputeInstanceGroup() *schema.Resource { ForceNew: true, }, + "zone": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + "instances": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "named_port": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -49,25 +61,14 @@ func resourceComputeInstanceGroup() *schema.Resource { }, }, - "instances": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "network": &schema.Schema{ Type: schema.TypeString, Computed: true, }, - "size": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - }, - - "zone": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, @@ -76,10 +77,9 @@ func resourceComputeInstanceGroup() *schema.Resource { Computed: true, }, - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, + "size": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_compute_instance_group_manager.go b/builtin/providers/google/resource_compute_instance_group_manager.go index 970722ae5e1b..21deac9d43e0 100644 --- a/builtin/providers/google/resource_compute_instance_group_manager.go +++ b/builtin/providers/google/resource_compute_instance_group_manager.go @@ -19,37 +19,43 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Delete: resourceComputeInstanceGroupManagerDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "base_instance_name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "description": &schema.Schema{ + "instance_template": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Required: true, + }, + + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, ForceNew: true, }, - "base_instance_name": &schema.Schema{ + "zone": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "fingerprint": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, - "instance_group": &schema.Schema{ + "fingerprint": &schema.Schema{ Type: schema.TypeString, Computed: true, }, - "instance_template": &schema.Schema{ + "instance_group": &schema.Schema{ Type: schema.TypeString, - Required: true, + Computed: true, }, "named_port": &schema.Schema{ @@ -57,7 +63,6 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -71,6 +76,17 @@ func resourceComputeInstanceGroupManager() *schema.Resource { }, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "update_strategy": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -89,23 +105,6 @@ func resourceComputeInstanceGroupManager() *schema.Resource { Computed: true, Optional: true, }, - - "zone": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index 5805fd2bb494..d836b977562c 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -16,37 +16,6 @@ func resourceComputeInstanceTemplate() *schema.Resource { Delete: resourceComputeInstanceTemplateDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "can_ip_forward": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, - ForceNew: true, - }, - - "instance_description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "machine_type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "disk": &schema.Schema{ Type: schema.TypeList, Required: true, @@ -123,12 +92,56 @@ func resourceComputeInstanceTemplate() *schema.Resource { }, }, + "machine_type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "automatic_restart": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + ForceNew: true, + Deprecated: "Please use `scheduling.automatic_restart` instead", + }, + + "can_ip_forward": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "instance_description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "metadata": &schema.Schema{ Type: schema.TypeMap, Optional: true, ForceNew: true, }, + "metadata_fingerprint": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "network_interface": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -164,14 +177,6 @@ func resourceComputeInstanceTemplate() *schema.Resource { }, }, - "automatic_restart": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: true, - ForceNew: true, - Deprecated: "Please use `scheduling.automatic_restart` instead", - }, - "on_host_maintenance": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -179,6 +184,18 @@ func resourceComputeInstanceTemplate() *schema.Resource { Deprecated: "Please use `scheduling.on_host_maintenance` instead", }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "region": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "scheduling": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -207,6 +224,11 @@ func resourceComputeInstanceTemplate() *schema.Resource { }, }, + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "service_account": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -242,32 +264,10 @@ func resourceComputeInstanceTemplate() *schema.Resource { Set: schema.HashString, }, - "metadata_fingerprint": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "tags_fingerprint": &schema.Schema{ Type: schema.TypeString, Computed: true, }, - - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_network.go b/builtin/providers/google/resource_compute_network.go index b3182ab148f0..3a08f7c405fa 100644 --- a/builtin/providers/google/resource_compute_network.go +++ b/builtin/providers/google/resource_compute_network.go @@ -22,18 +22,6 @@ func resourceComputeNetwork() *schema.Resource { ForceNew: true, }, - "ipv4_range": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Deprecated: "Please use google_compute_subnetwork resources instead.", - }, - - "gateway_ipv4": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "auto_create_subnetworks": &schema.Schema{ Type: schema.TypeBool, Optional: true, @@ -52,16 +40,28 @@ func resourceComputeNetwork() *schema.Resource { ForceNew: true, }, - "self_link": &schema.Schema{ + "gateway_ipv4": &schema.Schema{ Type: schema.TypeString, Computed: true, }, + "ipv4_range": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use google_compute_subnetwork resources instead.", + }, + "project": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_route.go b/builtin/providers/google/resource_compute_route.go index 0e177c895e26..82ea18064806 100644 --- a/builtin/providers/google/resource_compute_route.go +++ b/builtin/providers/google/resource_compute_route.go @@ -16,13 +16,13 @@ func resourceComputeRoute() *schema.Resource { Delete: resourceComputeRouteDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "dest_range": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "dest_range": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, @@ -34,7 +34,13 @@ func resourceComputeRoute() *schema.Resource { ForceNew: true, }, - "next_hop_ip": &schema.Schema{ + "priority": &schema.Schema{ + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + + "next_hop_gateway": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, @@ -52,7 +58,7 @@ func resourceComputeRoute() *schema.Resource { ForceNew: true, }, - "next_hop_gateway": &schema.Schema{ + "next_hop_ip": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, @@ -69,18 +75,10 @@ func resourceComputeRoute() *schema.Resource { ForceNew: true, }, - "priority": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - ForceNew: true, - }, - - "tags": &schema.Schema{ - Type: schema.TypeSet, + "project": &schema.Schema{ + Type: schema.TypeString, Optional: true, ForceNew: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, }, "self_link": &schema.Schema{ @@ -88,10 +86,12 @@ func resourceComputeRoute() *schema.Resource { Computed: true, }, - "project": &schema.Schema{ - Type: schema.TypeString, + "tags": &schema.Schema{ + Type: schema.TypeSet, Optional: true, ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, }, }, } diff --git a/builtin/providers/google/resource_compute_ssl_certificate.go b/builtin/providers/google/resource_compute_ssl_certificate.go index 8d7a4048b24a..8310b4403493 100644 --- a/builtin/providers/google/resource_compute_ssl_certificate.go +++ b/builtin/providers/google/resource_compute_ssl_certificate.go @@ -17,19 +17,13 @@ func resourceComputeSslCertificate() *schema.Resource { Delete: resourceComputeSslCertificateDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "certificate": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "certificate": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, @@ -41,9 +35,10 @@ func resourceComputeSslCertificate() *schema.Resource { ForceNew: true, }, - "self_link": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, "id": &schema.Schema{ @@ -56,6 +51,11 @@ func resourceComputeSslCertificate() *schema.Resource { Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_subnetwork.go b/builtin/providers/google/resource_compute_subnetwork.go index 9a0d2b423c7f..88ef4255af45 100644 --- a/builtin/providers/google/resource_compute_subnetwork.go +++ b/builtin/providers/google/resource_compute_subnetwork.go @@ -18,13 +18,13 @@ func resourceComputeSubnetwork() *schema.Resource { Delete: resourceComputeSubnetworkDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "ip_cidr_range": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "region": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, @@ -36,12 +36,6 @@ func resourceComputeSubnetwork() *schema.Resource { ForceNew: true, }, - "ip_cidr_range": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "description": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -53,16 +47,22 @@ func resourceComputeSubnetwork() *schema.Resource { Computed: true, }, - "self_link": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, - "project": &schema.Schema{ + "region": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -81,6 +81,11 @@ func splitSubnetID(id string) (region string, name string) { func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + project, err := getProject(d, config) if err != nil { return err @@ -93,7 +98,6 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e IpCidrRange: d.Get("ip_cidr_range").(string), Network: d.Get("network").(string), } - region := d.Get("region").(string) log.Printf("[DEBUG] Subnetwork insert request: %#v", subnetwork) op, err := config.clientCompute.Subnetworks.Insert( @@ -122,13 +126,17 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) + region, err := getRegion(d, config) + if err != nil { + return err + } + project, err := getProject(d, config) if err != nil { return err } name := d.Get("name").(string) - region := d.Get("region").(string) subnetwork, err := config.clientCompute.Subnetworks.Get( project, region, name).Do() @@ -153,12 +161,15 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - project, err := getProject(d, config) + region, err := getRegion(d, config) if err != nil { return err } - region := d.Get("region").(string) + project, err := getProject(d, config) + if err != nil { + return err + } // Delete the subnetwork op, err := config.clientCompute.Subnetworks.Delete( diff --git a/builtin/providers/google/resource_compute_target_http_proxy.go b/builtin/providers/google/resource_compute_target_http_proxy.go index cec71954d0c7..a85cddb5520d 100644 --- a/builtin/providers/google/resource_compute_target_http_proxy.go +++ b/builtin/providers/google/resource_compute_target_http_proxy.go @@ -24,15 +24,15 @@ func resourceComputeTargetHttpProxy() *schema.Resource { ForceNew: true, }, - "description": &schema.Schema{ + "url_map": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Required: true, }, - "self_link": &schema.Schema{ + "description": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, "id": &schema.Schema{ @@ -40,16 +40,16 @@ func resourceComputeTargetHttpProxy() *schema.Resource { Computed: true, }, - "url_map": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - "project": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_target_https_proxy.go b/builtin/providers/google/resource_compute_target_https_proxy.go index b505b0227666..041ae4b6bd51 100644 --- a/builtin/providers/google/resource_compute_target_https_proxy.go +++ b/builtin/providers/google/resource_compute_target_https_proxy.go @@ -24,6 +24,17 @@ func resourceComputeTargetHttpsProxy() *schema.Resource { ForceNew: true, }, + "ssl_certificates": &schema.Schema{ + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "url_map": &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "description": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -40,17 +51,6 @@ func resourceComputeTargetHttpsProxy() *schema.Resource { Computed: true, }, - "url_map": &schema.Schema{ - Type: schema.TypeString, - Required: true, - }, - - "ssl_certificates": &schema.Schema{ - Type: schema.TypeList, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "project": &schema.Schema{ Type: schema.TypeString, Optional: true, diff --git a/builtin/providers/google/resource_compute_target_pool.go b/builtin/providers/google/resource_compute_target_pool.go index 8ececab41d57..810f292f36a0 100644 --- a/builtin/providers/google/resource_compute_target_pool.go +++ b/builtin/providers/google/resource_compute_target_pool.go @@ -18,6 +18,12 @@ func resourceComputeTargetPool() *schema.Resource { Update: resourceComputeTargetPoolUpdate, Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "backup_pool": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -50,30 +56,24 @@ func resourceComputeTargetPool() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "name": &schema.Schema{ + "project": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "session_affinity": &schema.Schema{ + "region": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, - "region": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, - "project": &schema.Schema{ + "session_affinity": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, diff --git a/builtin/providers/google/resource_compute_url_map.go b/builtin/providers/google/resource_compute_url_map.go index 381ad9205575..303ff6688d71 100644 --- a/builtin/providers/google/resource_compute_url_map.go +++ b/builtin/providers/google/resource_compute_url_map.go @@ -18,20 +18,15 @@ func resourceComputeUrlMap() *schema.Resource { Delete: resourceComputeUrlMapDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "default_service": &schema.Schema{ Type: schema.TypeString, Required: true, - ForceNew: true, - }, - - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, }, - "default_service": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, }, "description": &schema.Schema{ @@ -68,6 +63,11 @@ func resourceComputeUrlMap() *schema.Resource { }, }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_matcher": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -110,6 +110,12 @@ func resourceComputeUrlMap() *schema.Resource { }, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "self_link": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -142,12 +148,6 @@ func resourceComputeUrlMap() *schema.Resource { }, }, }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_compute_vpn_gateway.go b/builtin/providers/google/resource_compute_vpn_gateway.go index 1e7de64b985a..1a10ec52d1d4 100644 --- a/builtin/providers/google/resource_compute_vpn_gateway.go +++ b/builtin/providers/google/resource_compute_vpn_gateway.go @@ -24,30 +24,35 @@ func resourceComputeVpnGateway() *schema.Resource { Required: true, ForceNew: true, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, + "network": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "self_link": &schema.Schema{ + + "description": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, - "region": &schema.Schema{ + + "project": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, - "project": &schema.Schema{ + + "region": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_compute_vpn_tunnel.go b/builtin/providers/google/resource_compute_vpn_tunnel.go index 4e94e4f0587d..96ff15d4ed1a 100644 --- a/builtin/providers/google/resource_compute_vpn_tunnel.go +++ b/builtin/providers/google/resource_compute_vpn_tunnel.go @@ -26,33 +26,44 @@ func resourceComputeVpnTunnel() *schema.Resource { Required: true, ForceNew: true, }, - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, + "peer_ip": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validatePeerAddr, }, + "shared_secret": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, + "target_vpn_gateway": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "detailed_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ike_version": &schema.Schema{ Type: schema.TypeInt, Optional: true, Default: 2, ForceNew: true, }, + "local_traffic_selector": &schema.Schema{ Type: schema.TypeSet, Optional: true, @@ -60,23 +71,22 @@ func resourceComputeVpnTunnel() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, - "detailed_status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "self_link": &schema.Schema{ + + "project": &schema.Schema{ Type: schema.TypeString, - Computed: true, + Optional: true, + ForceNew: true, }, + "region": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, - "project": &schema.Schema{ + + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_container_cluster.go b/builtin/providers/google/resource_container_cluster.go index 08dddaf27da8..e68fadff8489 100644 --- a/builtin/providers/google/resource_container_cluster.go +++ b/builtin/providers/google/resource_container_cluster.go @@ -21,60 +21,12 @@ func resourceContainerCluster() *schema.Resource { Delete: resourceContainerClusterDelete, Schema: map[string]*schema.Schema{ - "zone": &schema.Schema{ - Type: schema.TypeString, + "initial_node_count": &schema.Schema{ + Type: schema.TypeInt, Required: true, ForceNew: true, }, - "node_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - - "cluster_ipv4_cidr": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - _, ipnet, err := net.ParseCIDR(value) - - if err != nil || ipnet == nil || value != ipnet.String() { - errors = append(errors, fmt.Errorf( - "%q must contain a valid CIDR", k)) - } - return - }, - }, - - "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "endpoint": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - - "logging_service": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "monitoring_service": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - "master_auth": &schema.Schema{ Type: schema.TypeList, Required: true, @@ -93,13 +45,11 @@ func resourceContainerCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "password": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "username": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -136,6 +86,60 @@ func resourceContainerCluster() *schema.Resource { }, }, + "zone": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "cluster_ipv4_cidr": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + _, ipnet, err := net.ParseCIDR(value) + + if err != nil || ipnet == nil || value != ipnet.String() { + errors = append(errors, fmt.Errorf( + "%q must contain a valid CIDR", k)) + } + return + }, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "endpoint": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_group_urls": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "logging_service": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "monitoring_service": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "network": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -184,16 +188,10 @@ func resourceContainerCluster() *schema.Resource { }, }, - "initial_node_count": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - ForceNew: true, - }, - - "instance_group_urls": &schema.Schema{ - Type: schema.TypeList, + "node_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, }, "project": &schema.Schema{ diff --git a/builtin/providers/google/resource_dns_managed_zone.go b/builtin/providers/google/resource_dns_managed_zone.go index 913353593460..8181e278b645 100644 --- a/builtin/providers/google/resource_dns_managed_zone.go +++ b/builtin/providers/google/resource_dns_managed_zone.go @@ -16,13 +16,13 @@ func resourceDnsManagedZone() *schema.Resource { Delete: resourceDnsManagedZoneDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "dns_name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "dns_name": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, diff --git a/builtin/providers/google/resource_dns_record_set.go b/builtin/providers/google/resource_dns_record_set.go index 5f0b7a51ea97..22f9c60c3422 100644 --- a/builtin/providers/google/resource_dns_record_set.go +++ b/builtin/providers/google/resource_dns_record_set.go @@ -17,22 +17,25 @@ func resourceDnsRecordSet() *schema.Resource { Delete: resourceDnsRecordSetDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "managed_zone": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "managed_zone": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "type": &schema.Schema{ - Type: schema.TypeString, + "rrdatas": &schema.Schema{ + Type: schema.TypeList, Required: true, ForceNew: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, "ttl": &schema.Schema{ @@ -41,13 +44,10 @@ func resourceDnsRecordSet() *schema.Resource { ForceNew: true, }, - "rrdatas": &schema.Schema{ - Type: schema.TypeList, + "type": &schema.Schema{ + Type: schema.TypeString, Required: true, ForceNew: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, }, "project": &schema.Schema{ diff --git a/builtin/providers/google/resource_pubsub_subscription.go b/builtin/providers/google/resource_pubsub_subscription.go index 19f3f38e7662..432d48ee2f3b 100644 --- a/builtin/providers/google/resource_pubsub_subscription.go +++ b/builtin/providers/google/resource_pubsub_subscription.go @@ -20,12 +20,24 @@ func resourcePubsubSubscription() *schema.Resource { ForceNew: true, }, + "topic": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "ack_deadline_seconds": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, }, + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "push_config": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -47,18 +59,6 @@ func resourcePubsubSubscription() *schema.Resource { }, }, }, - - "topic": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_sql_database.go b/builtin/providers/google/resource_sql_database.go index 8ef245b1dfc1..c15e49ced6b7 100644 --- a/builtin/providers/google/resource_sql_database.go +++ b/builtin/providers/google/resource_sql_database.go @@ -22,20 +22,23 @@ func resourceSqlDatabase() *schema.Resource { Required: true, ForceNew: true, }, + "instance": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, + "project": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/google/resource_sql_database_instance.go b/builtin/providers/google/resource_sql_database_instance.go index a8945caad3b8..b8cc8730fbcc 100644 --- a/builtin/providers/google/resource_sql_database_instance.go +++ b/builtin/providers/google/resource_sql_database_instance.go @@ -19,32 +19,12 @@ func resourceSqlDatabaseInstance() *schema.Resource { Delete: resourceSqlDatabaseInstanceDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - "master_instance_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "database_version": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Default: "MYSQL_5_5", - ForceNew: true, - }, "region": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, + "settings": &schema.Schema{ Type: schema.TypeList, Required: true, @@ -170,6 +150,14 @@ func resourceSqlDatabaseInstance() *schema.Resource { }, }, }, + + "database_version": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "MYSQL_5_5", + ForceNew: true, + }, + "ip_address": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -187,6 +175,26 @@ func resourceSqlDatabaseInstance() *schema.Resource { }, }, }, + + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "master_instance_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "project": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "replica_configuration": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -246,10 +254,9 @@ func resourceSqlDatabaseInstance() *schema.Resource { }, }, - "project": &schema.Schema{ + "self_link": &schema.Schema{ Type: schema.TypeString, - Optional: true, - ForceNew: true, + Computed: true, }, }, } diff --git a/builtin/providers/google/resource_sql_user.go b/builtin/providers/google/resource_sql_user.go index b787ed040a53..2aaf1bd7a199 100644 --- a/builtin/providers/google/resource_sql_user.go +++ b/builtin/providers/google/resource_sql_user.go @@ -18,27 +18,27 @@ func resourceSqlUser() *schema.Resource { Delete: resourceSqlUserDelete, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "host": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "password": &schema.Schema{ + "instance": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, }, - "host": &schema.Schema{ + "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "instance": &schema.Schema{ + "password": &schema.Schema{ Type: schema.TypeString, Required: true, - ForceNew: true, }, "project": &schema.Schema{ diff --git a/builtin/providers/google/resource_storage_bucket.go b/builtin/providers/google/resource_storage_bucket.go index 105430765f27..8da47cab5e00 100644 --- a/builtin/providers/google/resource_storage_bucket.go +++ b/builtin/providers/google/resource_storage_bucket.go @@ -24,23 +24,38 @@ func resourceStorageBucket() *schema.Resource { Required: true, ForceNew: true, }, + + "force_destroy": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "location": &schema.Schema{ + Type: schema.TypeString, + Default: "US", + Optional: true, + ForceNew: true, + }, + "predefined_acl": &schema.Schema{ Type: schema.TypeString, Deprecated: "Please use resource \"storage_bucket_acl.predefined_acl\" instead.", Optional: true, ForceNew: true, }, - "location": &schema.Schema{ + + "project": &schema.Schema{ Type: schema.TypeString, - Default: "US", Optional: true, ForceNew: true, }, - "force_destroy": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, + + "self_link": &schema.Schema{ + Type: schema.TypeString, + Computed: true, }, + "website": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -57,15 +72,6 @@ func resourceStorageBucket() *schema.Resource { }, }, }, - "self_link": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - }, - "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, }, } } diff --git a/builtin/providers/google/resource_storage_bucket_acl.go b/builtin/providers/google/resource_storage_bucket_acl.go index 488fd85f455a..aa996cb9f211 100644 --- a/builtin/providers/google/resource_storage_bucket_acl.go +++ b/builtin/providers/google/resource_storage_bucket_acl.go @@ -24,20 +24,23 @@ func resourceStorageBucketAcl() *schema.Resource { Required: true, ForceNew: true, }, + + "default_acl": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "predefined_acl": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + "role_entity": &schema.Schema{ Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "default_acl": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, }, } } diff --git a/builtin/providers/google/resource_storage_bucket_object.go b/builtin/providers/google/resource_storage_bucket_object.go index 679c7e74e5d5..a129f73cf348 100644 --- a/builtin/providers/google/resource_storage_bucket_object.go +++ b/builtin/providers/google/resource_storage_bucket_object.go @@ -32,13 +32,6 @@ func resourceStorageBucketObject() *schema.Resource { ForceNew: true, }, - "source": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ConflictsWith: []string{"content"}, - }, - "content": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -46,11 +39,9 @@ func resourceStorageBucketObject() *schema.Resource { ConflictsWith: []string{"source"}, }, - "predefined_acl": &schema.Schema{ - Type: schema.TypeString, - Deprecated: "Please use resource \"storage_object_acl.predefined_acl\" instead.", - Optional: true, - ForceNew: true, + "crc32c": &schema.Schema{ + Type: schema.TypeString, + Computed: true, }, "md5hash": &schema.Schema{ @@ -58,9 +49,18 @@ func resourceStorageBucketObject() *schema.Resource { Computed: true, }, - "crc32c": &schema.Schema{ - Type: schema.TypeString, - Computed: true, + "predefined_acl": &schema.Schema{ + Type: schema.TypeString, + Deprecated: "Please use resource \"storage_object_acl.predefined_acl\" instead.", + Optional: true, + ForceNew: true, + }, + + "source": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ConflictsWith: []string{"content"}, }, }, } diff --git a/builtin/providers/google/resource_storage_object_acl.go b/builtin/providers/google/resource_storage_object_acl.go index e4968265f736..a73e34b39a6c 100644 --- a/builtin/providers/google/resource_storage_object_acl.go +++ b/builtin/providers/google/resource_storage_object_acl.go @@ -23,21 +23,24 @@ func resourceStorageObjectAcl() *schema.Resource { Required: true, ForceNew: true, }, + "object": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "role_entity": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, + "predefined_acl": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, + + "role_entity": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, } } diff --git a/website/source/docs/providers/google/index.html.markdown b/website/source/docs/providers/google/index.html.markdown index 5aee7215420d..641e2b419093 100644 --- a/website/source/docs/providers/google/index.html.markdown +++ b/website/source/docs/providers/google/index.html.markdown @@ -16,17 +16,17 @@ Use the navigation to the left to read about the available resources. ## Example Usage -``` -# Configure the Google Cloud provider +```js +// Configure the Google Cloud provider provider "google" { credentials = "${file("account.json")}" project = "my-gce-project" region = "us-central1" } -# Create a new instance +// Create a new instance resource "google_compute_instance" "default" { - ... + // ... } ``` diff --git a/website/source/docs/providers/google/r/compute_address.html.markdown b/website/source/docs/providers/google/r/compute_address.html.markdown index 2b695df8cc99..8d5655b14d2c 100644 --- a/website/source/docs/providers/google/r/compute_address.html.markdown +++ b/website/source/docs/providers/google/r/compute_address.html.markdown @@ -8,16 +8,16 @@ description: |- # google\_compute\_address -Creates a static IP address resource for Google Compute Engine. For more information see +Creates a static IP address resource for Google Compute Engine. For more information see [the official documentation](https://cloud.google.com/compute/docs/instances-and-network) and [API](https://cloud.google.com/compute/docs/reference/latest/addresses). ## Example Usage -``` +```js resource "google_compute_address" "default" { - name = "test-address" + name = "test-address" } ``` @@ -27,14 +27,18 @@ The following arguments are supported: * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. + +- - - + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + * `region` - (Optional) The Region in which the created address should reside. If it is not provided, the provider region is used. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `address` - The IP address that was allocated. * `self_link` - The URI of the created resource. -* `region` - The Region in which the created address does reside. diff --git a/website/source/docs/providers/google/r/compute_autoscaler.html.markdown b/website/source/docs/providers/google/r/compute_autoscaler.html.markdown index 381caf09fbc7..3d18ed651be5 100644 --- a/website/source/docs/providers/google/r/compute_autoscaler.html.markdown +++ b/website/source/docs/providers/google/r/compute_autoscaler.html.markdown @@ -12,7 +12,7 @@ A Compute Engine Autoscaler automatically adds or removes virtual machines from a managed instance group based on increases or decreases in load. This allows your applications to gracefully handle increases in traffic and reduces cost when the need for resources is lower. You just define the autoscaling policy and -the autoscaler performs automatic scaling based on the measured load. For more +the autoscaler performs automatic scaling based on the measured load. For more information, see [the official documentation](https://cloud.google.com/compute/docs/autoscaler/) and [API](https://cloud.google.com/compute/docs/autoscaler/v1beta2/autoscalers) @@ -20,54 +20,58 @@ documentation](https://cloud.google.com/compute/docs/autoscaler/) and ## Example Usage -``` +```js resource "google_compute_instance_template" "foobar" { - name = "foobar" - machine_type = "n1-standard-1" - can_ip_forward = false - tags = ["foo", "bar"] + name = "foobar" + machine_type = "n1-standard-1" + can_ip_forward = false - disk { - source_image = "debian-cloud/debian-7-wheezy-v20160301" - } + tags = ["foo", "bar"] - network_interface { - network = "default" - } + disk { + source_image = "debian-cloud/debian-7-wheezy-v20160301" + } - metadata { - foo = "bar" - } + network_interface { + network = "default" + } - service_account { - scopes = ["userinfo-email", "compute-ro", "storage-ro"] - } + metadata { + foo = "bar" + } + + service_account { + scopes = ["userinfo-email", "compute-ro", "storage-ro"] + } } resource "google_compute_target_pool" "foobar" { - name = "foobar" + name = "foobar" } resource "google_compute_instance_group_manager" "foobar" { - name = "foobar" - instance_template = "${google_compute_instance_template.foobar.self_link}" - target_pools = ["${google_compute_target_pool.foobar.self_link}"] - base_instance_name = "foobar" - zone = "us-central1-f" + name = "foobar" + zone = "us-central1-f" + + instance_template = "${google_compute_instance_template.foobar.self_link}" + target_pools = ["${google_compute_target_pool.foobar.self_link}"] + base_instance_name = "foobar" } resource "google_compute_autoscaler" "foobar" { - name = "foobar" - zone = "us-central1-f" - target = "${google_compute_instance_group_manager.foobar.self_link}" - autoscaling_policy = { - max_replicas = 5 - min_replicas = 1 - cooldown_period = 60 - cpu_utilization = { - target = 0.5 - } + name = "foobar" + zone = "us-central1-f" + target = "${google_compute_instance_group_manager.foobar.self_link}" + + autoscaling_policy = { + max_replicas = 5 + min_replicas = 1 + cooldown_period = 60 + + cpu_utilization { + target = 0.5 } + } } ``` @@ -75,16 +79,23 @@ resource "google_compute_autoscaler" "foobar" { The following arguments are supported: -* `description` - (Optional) An optional textual description of the instance -group manager. +* `name` - (Required) The name of the autoscaler. * `target` - (Required) The full URL to the instance group manager whose size we control. +* `zone` - (Required) The zone of the target. + * `autoscaling_policy.` - (Required) The parameters of the autoscaling - algorithm. Structure is documented below. + algorithm. Structure is documented below. -* `zone` - (Required) The zone of the target. +- - - + +* `description` - (Optional) An optional textual description of the instance + group manager. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. The `autoscaling_policy` block contains: @@ -92,22 +103,22 @@ The `autoscaling_policy` block contains: * `min_replicas` - (Required) The group will never be smaller than this. -* `cooldown_period` - (Optional) Period to wait between changes. This should be +* `cooldown_period` - (Optional) Period to wait between changes. This should be at least double the time your instances take to start up. * `cpu_utilization` - (Optional) A policy that scales when the cluster's average - CPU is above or below a given threshold. Structure is documented below. + CPU is above or below a given threshold. Structure is documented below. * `metric` - (Optional) A policy that scales according to Google Cloud Monitoring metrics Structure is documented below. * `load_balancing_utilization` - (Optional) A policy that scales when the load - reaches a proportion of a limit defined in the HTTP load balancer. Structure + reaches a proportion of a limit defined in the HTTP load balancer. Structure is documented below. The `cpu_utilization` block contains: -* `target` - The floating point threshold where CPU utilization should be. E.g. +* `target` - The floating point threshold where CPU utilization should be. E.g. for 50% one would specify 0.5. The `metric` block contains (more documentation @@ -118,18 +129,19 @@ The `metric` block contains (more documentation * `type` - Either "cumulative", "delta", or "gauge". -* `target` - The desired metric value per instance. Must be a positive value. +* `target` - The desired metric value per instance. Must be a positive value. The `load_balancing_utilization` block contains: * `target` - The floating point threshold where load balancing utilization - should be. E.g. if the load balancer's `maxRatePerInstance` is 10 requests + should be. E.g. if the load balancer's `maxRatePerInstance` is 10 requests per second (RPS) then setting this to 0.5 would cause the group to be scaled such that each instance receives 5 RPS. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: * `self_link` - The URL of the created resource. diff --git a/website/source/docs/providers/google/r/compute_backend_service.html.markdown b/website/source/docs/providers/google/r/compute_backend_service.html.markdown index 1fbc403bf97a..9bfbe3bdc3aa 100644 --- a/website/source/docs/providers/google/r/compute_backend_service.html.markdown +++ b/website/source/docs/providers/google/r/compute_backend_service.html.markdown @@ -12,50 +12,49 @@ A Backend Service defines a group of virtual machines that will serve traffic fo ## Example Usage -``` +```js resource "google_compute_backend_service" "foobar" { - name = "blablah" - description = "Hello World 1234" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" - - backend { - group = "${google_compute_instance_group_manager.foo.instance_group}" - } - - health_checks = ["${google_compute_http_health_check.default.self_link}"] + name = "blablah" + description = "Hello World 1234" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 + + backend { + group = "${google_compute_instance_group_manager.foo.instance_group}" + } + + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_instance_group_manager" "foo" { - name = "terraform-test" - instance_template = "${google_compute_instance_template.foobar.self_link}" - base_instance_name = "foobar" - zone = "us-central1-f" - target_size = 1 + name = "terraform-test" + instance_template = "${google_compute_instance_template.foobar.self_link}" + base_instance_name = "foobar" + zone = "us-central1-f" + target_size = 1 } resource "google_compute_instance_template" "foobar" { - name = "terraform-test" - machine_type = "n1-standard-1" - - network_interface { - network = "default" - } - - disk { - source_image = "debian-7-wheezy-v20160301" - auto_delete = true - boot = true - } + name = "terraform-test" + machine_type = "n1-standard-1" + + network_interface { + network = "default" + } + + disk { + source_image = "debian-7-wheezy-v20160301" + auto_delete = true + boot = true + } } resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 } ``` @@ -64,31 +63,64 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: * `name` - (Required) The name of the backend service. + * `health_checks` - (Required) Specifies a list of HTTP health check objects for checking the health of the backend service. + +- - - + +* `backend` - (Optional) The list of backends that serve this BackendService. + See *Backend* below. + * `description` - (Optional) The textual description for the backend service. -* `backend` - (Optional) The list of backends that serve this BackendService. See *Backend* below. -* `region` - (Optional) The region the service sits in. If not specified, the project region is used. -* `port_name` - (Optional) The name of a service that has been added to - an instance group in this backend. See [related docs](https://cloud.google.com/compute/docs/instance-groups/#specifying_service_endpoints) - for details. Defaults to http. -* `protocol` - (Optional) The protocol for incoming requests. Defaults to `HTTP`. + +* `port_name` - (Optional) The name of a service that has been added to an + instance group in this backend. See [related docs](https://cloud.google.com/compute/docs/instance-groups/#specifying_service_endpoints) for details. Defaults to http. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `protocol` - (Optional) The protocol for incoming requests. Defaults to + `HTTP`. + +* `region` - (Optional) The Region in which the created address should reside. + If it is not provided, the provider region is used. + * `timeout_sec` - (Optional) The number of secs to wait for a backend to respond - to a request before considering the request failed. Defaults to `30`. + to a request before considering the request failed. Defaults to `30`. + **Backend** supports the following attributes: -* `group` - (Required) The name or URI of a Compute Engine instance group (`google_compute_instance_group_manager.xyz.instance_group`) that can receive traffic. -* `balancing_mode` - (Optional) Defines the strategy for balancing load. Defaults to `UTILIZATION` -* `capacity_scaler` - (Optional) A float in the range [0, 1.0] that scales the maximum parameters for the group (e.g., max rate). A value of 0.0 will cause no requests to be sent to the group (i.e., it adds the group in a drained state). The default is 1.0. +* `group` - (Required) The name or URI of a Compute Engine instance group + (`google_compute_instance_group_manager.xyz.instance_group`) that can + receive traffic. + +* `balancing_mode` - (Optional) Defines the strategy for balancing load. + Defaults to `UTILIZATION` + +* `capacity_scaler` - (Optional) A float in the range [0, 1.0] that scales the + maximum parameters for the group (e.g., max rate). A value of 0.0 will cause + no requests to be sent to the group (i.e., it adds the group in a drained + state). The default is 1.0. + * `description` - (Optional) Textual description for the backend. -* `max_rate` - (Optional) Maximum requests per second (RPS) that the group can handle. -* `max_rate_per_instance` - (Optional) The maximum per-instance requests per second (RPS). -* `max_utilization` - (Optional) The target CPU utilization for the group as a float in the range [0.0, 1.0]. This flag can only be provided when the balancing mode is `UTILIZATION`. Defaults to `0.8`. + +* `max_rate` - (Optional) Maximum requests per second (RPS) that the group can + handle. + +* `max_rate_per_instance` - (Optional) The maximum per-instance requests per + second (RPS). + +* `max_utilization` - (Optional) The target CPU utilization for the group as a + float in the range [0.0, 1.0]. This flag can only be provided when the + balancing mode is `UTILIZATION`. Defaults to `0.8`. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `fingerprint` - The fingerprint of the backend service. -* `name` - The name of the resource. * `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_disk.html.markdown b/website/source/docs/providers/google/r/compute_disk.html.markdown index e6fe353f714d..3d61dd6b8440 100644 --- a/website/source/docs/providers/google/r/compute_disk.html.markdown +++ b/website/source/docs/providers/google/r/compute_disk.html.markdown @@ -12,12 +12,12 @@ Creates a new persistent disk within GCE, based on another disk. ## Example Usage -``` +```js resource "google_compute_disk" "default" { - name = "test-disk" - type = "pd-ssd" - zone = "us-central1-a" - image = "debian7-wheezy" + name = "test-disk" + type = "pd-ssd" + zone = "us-central1-a" + image = "debian7-wheezy" } ``` @@ -30,22 +30,25 @@ The following arguments are supported: * `zone` - (Required) The zone where this disk will be available. -* `image` - (Optional) The image from which to initialize this disk. Either the full URL, a - contraction of the form "project/name", or just a name (in which case the current project is -used). +- - - + +* `image` - (Optional) The image from which to initialize this disk. Either the + full URL, a contraction of the form "project/name", or just a name (in which + case the current project is used). + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -* `snapshot` - (Optional) Name of snapshot from which to initialize this disk; +* `size` - (Optional) The size of the image in gigabytes. If not specified, it + will inherit the size of its base image. -* `size` - (Optional) The size of the image in gigabytes. If not specified, - it will inherit the size of its base image. +* `snapshot` - (Optional) Name of snapshot from which to initialize this disk. * `type` - (Optional) The GCE disk type. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `zone` - The zone where the resource is located. -* `image` - The name of the image the disk is based off of. -* `size` - The size of the disk in gigabytes. +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_firewall.html.markdown b/website/source/docs/providers/google/r/compute_firewall.html.markdown index f65741502f6e..c495b3a1c331 100644 --- a/website/source/docs/providers/google/r/compute_firewall.html.markdown +++ b/website/source/docs/providers/google/r/compute_firewall.html.markdown @@ -12,21 +12,21 @@ Manages a firewall resource within GCE. ## Example Usage -``` +```js resource "google_compute_firewall" "default" { - name = "test" - network = "${google_compute_network.other.name}" + name = "test" + network = "${google_compute_network.other.name}" - allow { - protocol = "icmp" - } + allow { + protocol = "icmp" + } - allow { - protocol = "tcp" - ports = ["80", "8080", "1000-2000"] - } + allow { + protocol = "tcp" + ports = ["80", "8080", "1000-2000"] + } - source_tags = ["web"] + source_tags = ["web"] } ``` @@ -37,19 +37,24 @@ The following arguments are supported: * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -* `description` - (Optional) Textual description field. - * `network` - (Required) The name of the network to attach this firewall to. * `allow` - (Required) Can be specified multiple times for each allow rule. Each allow block supports fields documented below. +- - - + +* `description` - (Optional) Textual description field. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + * `source_ranges` - (Optional) A list of source CIDR ranges that this firewall applies to. -* `source_tags` - (Optional) A list of source tags that this firewall applies to. +* `source_tags` - (Optional) A list of source tags for this firewall. -* `target_tags` - (Optional) A list of target tags that this firewall applies to. +* `target_tags` - (Optional) A list of target tags for this firewall. The `allow` block supports: @@ -60,9 +65,7 @@ The `allow` block supports: ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `network` - The network that this resource is attached to. -* `source_ranges` - The CIDR block ranges this firewall applies to. -* `source_tags` - The tags that this firewall applies to. +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_forwarding_rule.html.markdown b/website/source/docs/providers/google/r/compute_forwarding_rule.html.markdown index 582f36af8ea2..056055c06b9e 100644 --- a/website/source/docs/providers/google/r/compute_forwarding_rule.html.markdown +++ b/website/source/docs/providers/google/r/compute_forwarding_rule.html.markdown @@ -8,18 +8,18 @@ description: |- # google\_compute\_forwarding\_rule -Manages a Forwarding Rule within GCE. This binds an ip and port range to a target pool. For more +Manages a Forwarding Rule within GCE. This binds an ip and port range to a target pool. For more information see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules) and [API](https://cloud.google.com/compute/docs/reference/latest/forwardingRules). ## Example Usage -``` +```js resource "google_compute_forwarding_rule" "default" { - name = "test" - target = "${google_compute_target_pool.default.self_link}" - port_range = "80" + name = "test" + target = "${google_compute_target_pool.default.self_link}" + port_range = "80" } ``` @@ -27,27 +27,33 @@ resource "google_compute_forwarding_rule" "default" { The following arguments are supported: -* `description` - (Optional) Textual description field. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. -* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is -used). +* `target` - (Required) URL of target pool. -* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH" "ESP" or "SCTP". (default "TCP"). +- - - -* `name` - (Required) A unique name for the resource, required by GCE. Changing - this forces a new resource to be created. +* `description` - (Optional) Textual description field. -* `port_range` - (Optional) A range e.g. "1024-2048" or a single port "1024" -(defaults to all ports!). +* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is + used). -* `target` - URL of target pool. +* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH" + "ESP" or "SCTP". (default "TCP"). -## Attributes Reference +* `port_range` - (Optional) A range e.g. "1024-2048" or a single port "1024" + (defaults to all ports!). -The following attributes are exported: +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -* `self_link` - The URL of the created resource. +* `region` - (Optional) The Region in which the created address should reside. + If it is not provided, the provider region is used. -* `ip_address` - The IP address that was chosen (or specified). +## Attributes Reference +In addition to the arguments listed above, the following computed attributes are +exported: +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_global_address.html.markdown b/website/source/docs/providers/google/r/compute_global_address.html.markdown index bf2989c1c92b..dbfab293773a 100644 --- a/website/source/docs/providers/google/r/compute_global_address.html.markdown +++ b/website/source/docs/providers/google/r/compute_global_address.html.markdown @@ -15,9 +15,9 @@ Creates a static IP address resource global to a Google Compute Engine project. ## Example Usage -``` +```js resource "google_compute_global_address" "default" { - name = "test-address" + name = "test-address" } ``` @@ -28,10 +28,16 @@ The following arguments are supported: * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. +- - - + +* `project` - (Optional) The project in which the resource belongs. If it +is not provided, the provider project is used. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `address` - The assigned address. -* `name` - The name of the resource. -* `address` - The IP address that was allocated. * `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_global_forwarding_rule.html.markdown b/website/source/docs/providers/google/r/compute_global_forwarding_rule.html.markdown index a336ab59cdfd..7f39d4e296bc 100644 --- a/website/source/docs/providers/google/r/compute_global_forwarding_rule.html.markdown +++ b/website/source/docs/providers/google/r/compute_global_forwarding_rule.html.markdown @@ -1,68 +1,67 @@ --- layout: "google" page_title: "Google: google_compute_global_forwarding_rule" -sidebar_current: "docs-google-compute-global-forwarding_rule" +sidebar_current: "docs-google-compute-global-forwarding-rule" description: |- Manages a Target Pool within GCE. --- # google\_compute\_global\_forwarding\_rule -Manages a Global Forwarding Rule within GCE. This binds an ip and port to a target HTTP(s) proxy. For more +Manages a Global Forwarding Rule within GCE. This binds an ip and port to a target HTTP(s) proxy. For more information see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules) and [API](https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules). ## Example Usage -``` +```js resource "google_compute_global_forwarding_rule" "default" { - name = "test" - target = "${google_compute_target_http_proxy.default.self_link}" - port_range = "80" + name = "test" + target = "${google_compute_target_http_proxy.default.self_link}" + port_range = "80" } resource "google_compute_target_http_proxy" "default" { - name = "test-proxy" - description = "a description" - url_map = "${google_compute_url_map.default.self_link}" + name = "test-proxy" + description = "a description" + url_map = "${google_compute_url_map.default.self_link}" } resource "google_compute_url_map" "default" { - name = "url-map" - description = "a description" - default_service = "${google_compute_backend_service.default.self_link}" + name = "url-map" + description = "a description" + default_service = "${google_compute_backend_service.default.self_link}" - host_rule { - hosts = ["mysite.com"] - path_matcher = "allpaths" - } + host_rule { + hosts = ["mysite.com"] + path_matcher = "allpaths" + } - path_matcher { - default_service = "${google_compute_backend_service.default.self_link}" - name = "allpaths" - path_rule { - paths = ["/*"] - service = "${google_compute_backend_service.default.self_link}" - } + path_matcher { + name = "allpaths" + default_service = "${google_compute_backend_service.default.self_link}" + path_rule { + paths = ["/*"] + service = "${google_compute_backend_service.default.self_link}" } + } } resource "google_compute_backend_service" "default" { - name = "default-backend" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" + name = "default-backend" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 - health_checks = ["${google_compute_http_health_check.default.self_link}"] + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 } ``` @@ -70,24 +69,30 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: -* `description` - (Optional) Textual description field. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. -* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is used). +* `target` - (Required) URL of target HTTP or HTTPS proxy. -* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH" "ESP" or "SCTP". (default "TCP"). +- - - -* `name` - (Required) A unique name for the resource, required by GCE. Changing - this forces a new resource to be created. +* `description` - (Optional) Textual description field. + +* `ip_address` - (Optional) The static IP. (if not set, an ephemeral IP is + used). + +* `ip_protocol` - (Optional) The IP protocol to route, one of "TCP" "UDP" "AH" + "ESP" or "SCTP". (default "TCP"). * `port_range` - (Optional) A range e.g. "1024-2048" or a single port "1024" - (defaults to all ports!). + (defaults to all ports!). -* `target` - URL of target HTTP or HTTPS proxy. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. ## Attributes Reference -The following attributes are exported: - -* `self_link` - The URL of the created resource. +In addition to the arguments listed above, the following computed attributes are +exported: -* `ip_address` - The IP address that was chosen (or specified). +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_http_health_check.html.markdown b/website/source/docs/providers/google/r/compute_http_health_check.html.markdown index 32f28c772290..230386555858 100644 --- a/website/source/docs/providers/google/r/compute_http_health_check.html.markdown +++ b/website/source/docs/providers/google/r/compute_http_health_check.html.markdown @@ -8,21 +8,22 @@ description: |- # google\_compute\_http\_health\_check -Manages an HTTP health check within GCE. This is used to monitor instances -behind load balancers. Timeouts or HTTP errors cause the instance to be -removed from the pool. For more information, see [the official +Manages an HTTP health check within GCE. This is used to monitor instances +behind load balancers. Timeouts or HTTP errors cause the instance to be +removed from the pool. For more information, see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/health-checks) and [API](https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks). ## Example Usage -``` +```js resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/health_check" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/health_check" + + timeout_sec = 1 + check_interval_sec = 1 } ``` @@ -30,7 +31,13 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: -* `check_interval_sec` - (Optional) How often to poll each instance (default 5). +* `name` - (Required) A unique name for the resource, required by GCE. + Changing this forces a new resource to be created. + +- - - + +* `check_interval_sec` - (Optional) The number of seconds between each poll of + the instance instance (default 5). * `description` - (Optional) Textual description field. @@ -38,20 +45,22 @@ The following arguments are supported: * `host` - (Optional) HTTP host header field (default instance's public ip). -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. - * `port` - (Optional) TCP port to connect to (default 80). +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + * `request_path` - (Optional) URL path to query (default /). -* `timeout_sec` - (Optional) How long before declaring failure (default 5). +* `timeout_sec` - (Optional) The number of seconds to wait before declaring + failure (default 5). * `unhealthy_threshold` - (Optional) Consecutive failures required (default 2). ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `self_link` - The URL of the created resource. +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_https_health_check.html.markdown b/website/source/docs/providers/google/r/compute_https_health_check.html.markdown index f608cac3639a..e04054bcc2d4 100644 --- a/website/source/docs/providers/google/r/compute_https_health_check.html.markdown +++ b/website/source/docs/providers/google/r/compute_https_health_check.html.markdown @@ -8,21 +8,22 @@ description: |- # google\_compute\_https\_health\_check -Manages an HTTPS health check within GCE. This is used to monitor instances -behind load balancers. Timeouts or HTTPS errors cause the instance to be -removed from the pool. For more information, see [the official +Manages an HTTPS health check within GCE. This is used to monitor instances +behind load balancers. Timeouts or HTTPS errors cause the instance to be +removed from the pool. For more information, see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/health-checks) and [API](https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks). ## Example Usage -``` +```js resource "google_compute_https_health_check" "default" { - name = "test" - request_path = "/health_check" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/health_check" + + timeout_sec = 1 + check_interval_sec = 1 } ``` @@ -30,6 +31,11 @@ resource "google_compute_https_health_check" "default" { The following arguments are supported: +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. + +- - - + * `check_interval_sec` - (Optional) How often to poll each instance (default 5). * `description` - (Optional) Textual description field. @@ -38,11 +44,11 @@ The following arguments are supported: * `host` - (Optional) HTTPS host header field (default instance's public ip). -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. - * `port` - (Optional) TCP port to connect to (default 443). +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + * `request_path` - (Optional) URL path to query (default /). * `timeout_sec` - (Optional) How long before declaring failure (default 5). diff --git a/website/source/docs/providers/google/r/compute_instance.html.markdown b/website/source/docs/providers/google/r/compute_instance.html.markdown index 543391bc0c40..6f842394b1c0 100644 --- a/website/source/docs/providers/google/r/compute_instance.html.markdown +++ b/website/source/docs/providers/google/r/compute_instance.html.markdown @@ -8,7 +8,7 @@ description: |- # google\_compute\_instance -Manages a VM instance resource within GCE. For more information see +Manages a VM instance resource within GCE. For more information see [the official documentation](https://cloud.google.com/compute/docs/instances) and [API](https://cloud.google.com/compute/docs/reference/latest/instances). @@ -16,39 +16,40 @@ and ## Example Usage -``` +```js resource "google_compute_instance" "default" { - name = "test" - machine_type = "n1-standard-1" - zone = "us-central1-a" - tags = ["foo", "bar"] - - disk { - image = "debian-7-wheezy-v20160301" - } - - // Local SSD disk - disk { - type = "local-ssd" - scratch = true - } - - network_interface { - network = "default" - access_config { - // Ephemeral IP - } - } - - metadata { - foo = "bar" - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - scopes = ["userinfo-email", "compute-ro", "storage-ro"] - } + name = "test" + machine_type = "n1-standard-1" + zone = "us-central1-a" + + tags = ["foo", "bar"] + + disk { + image = "debian-7-wheezy-v20160301" + } + + // Local SSD disk + disk { + type = "local-ssd" + scratch = true + } + + network_interface { + network = "default" + access_config { + // Ephemeral IP + } + } + + metadata { + foo = "bar" + } + + metadata_startup_script = "echo hi > /test.txt" + + service_account { + scopes = ["userinfo-email", "compute-ro", "storage-ro"] + } } ``` @@ -56,39 +57,48 @@ resource "google_compute_instance" "default" { The following arguments are supported: -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. +* `disk` - (Required) Disks to attach to the instance. This can be specified + multiple times for multiple disks. Structure is documented below. -* `description` - (Optional) A brief description of this resource. +* `machine_type` - (Required) The machine type to create.To create a custom + machine type, value should be set as specified + [here](https://cloud.google.com/compute/docs/reference/latest/instances#machineType) -* `machine_type` - (Required) The machine type to create.To create a custom machine type, value should be - set as specified [here](https://cloud.google.com/compute/docs/reference/latest/instances#machineType) +* `name` - (Required) A unique name for the resource, required by GCE. + Changing this forces a new resource to be created. * `zone` - (Required) The zone that the machine should be created in. -* `disk` - (Required) Disks to attach to the instance. This can be specified - multiple times for multiple disks. Structure is documented below. +- - - * `can_ip_forward` - (Optional) Whether to allow sending and receiving of packets with non-matching source or destination IPs. This defaults to false. +* `description` - (Optional) A brief description of this resource. + * `metadata` - (Optional) Metadata key/value pairs to make available from within the instance. * `metadata_startup_script` - (Optional) An alternative to using the - startup-script metadata key, except this one forces the instance to be - recreated (thus re-running the script) if it is changed. This replaces the - startup-script metadata key on the created instance and thus the two mechanisms - are not allowed to be used simultaneously. + startup-script metadata key, except this one forces the instance to be + recreated (thus re-running the script) if it is changed. This replaces the + startup-script metadata key on the created instance and thus the two + mechanisms are not allowed to be used simultaneously. -* `network_interface` - (Required) Networks to attach to the instance. This can be - specified multiple times for multiple networks, but GCE is currently limited - to just 1. Structure is documented below. +* `network_interface` - (Required) Networks to attach to the instance. This can + be specified multiple times for multiple networks, but GCE is currently + limited to just 1. Structure is documented below. -* `network` - (DEPRECATED, Required) Networks to attach to the instance. This can be - specified multiple times for multiple networks. Structure is documented - below. +* `network` - (DEPRECATED, Required) Networks to attach to the instance. This + can be specified multiple times for multiple networks. Structure is + documented below. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `scheduling` - (Optional) The scheduling strategy to use. More details about + this configuration option are detailed below. * `service_account` - (Optional) Service account to attach to the instance. @@ -98,14 +108,14 @@ The `disk` block supports: (Note that either disk or image is required, unless the type is "local-ssd", in which case scratch must be true). * `disk` - The name of the existing disk (such as those managed by - `google_compute_disk`) to attach. + `google_compute_disk`) to attach. * `image` - The image from which to initialize this - disk. Either the full URL, a contraction of the form "project/name", or just - a name (in which case the current project is used). + disk. Either the full URL, a contraction of the form "project/name", or + just a name (in which case the current project is used). * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. - This defaults to true. Leave true for local SSDs. + This defaults to true. Leave true for local SSDs. * `type` - (Optional) The GCE disk type, e.g. pd-standard, pd-ssd, or local-ssd. @@ -113,7 +123,7 @@ the type is "local-ssd", in which case scratch must be true). persistent disk (required for local-ssd). * `size` - (Optional) The size of the image in gigabytes. If not specified, it - will inherit the size of its base image. Do not specify for local SSDs as + will inherit the size of its base image. Do not specify for local SSDs as their size is fixed. * `device_name` - (Optional) Name with which attached disk will be accessible @@ -121,34 +131,36 @@ the type is "local-ssd", in which case scratch must be true). The `network_interface` block supports: -* `network` - (Optional) The name of the network to attach this interface to. Either - `network` or `subnetwork` must be provided. +* `network` - (Optional) The name of the network to attach this interface to. + Either `network` or `subnetwork` must be provided. -* `subnetwork` - (Optional) the name of the subnetwork to attach this interface to. The subnetwork - must exist in the same region this instance will be created in. Either `network` - or `subnetwork` must be provided. +* `subnetwork` - (Optional) the name of the subnetwork to attach this interface + to. The subnetwork must exist in the same region this instance will be + created in. Either `network` or `subnetwork` must be provided. -* `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be - accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet -(this means that ssh provisioners will not work unless you are running Terraform can send traffic to -the instance's network (e.g. via tunnel or because it is running on another cloud instance on that -network). This block can be repeated multiple times. Structure documented below. +* `access_config` - (Optional) Access configurations, i.e. IPs via which this + instance can be accessed via the Internet. Omit to ensure that the instance + is not accessible from the Internet (this means that ssh provisioners will + not work unless you are running Terraform can send traffic tothe instance's + network (e.g. via tunnel or because it is running on another cloud instance + on that network). This block can be repeated multiple times. Structure + documented below. The `access_config` block supports: -* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip. If not - given, one will be generated. +* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's + network ip. If not given, one will be generated. * `assigned_nat_ip` - (Optional) The IP address that is assigned to the - instance. If `nat_ip` is filled, it will appear here. If `nat_ip` is left - blank, the ephemeral assigned IP will appear here. + instance. If `nat_ip` is filled, it will appear here. If `nat_ip` is left + blank, the ephemeral assigned IP will appear here. (DEPRECATED) The `network` block supports: * `source` - (Required) The name of the network to attach this interface to. * `address` - (Optional) The IP address of a reserved IP address to assign - to this interface. + to this interface. The `service_account` block supports: @@ -159,8 +171,8 @@ The `scheduling` block supports: * `preemptible` - (Optional) Is the instance preemptible. -* `on_host_maintenance` - (Optional) Describes maintenance behavior for - the instance. Can be MIGRATE or TERMINATE, for more info, read +* `on_host_maintenance` - (Optional) Describes maintenance behavior for the + instance. Can be MIGRATE or TERMINATE, for more info, read [here](https://cloud.google.com/compute/docs/instances/setting-instance-scheduling-options) * `automatic_restart` - (Optional) Specifies if the instance should be @@ -168,8 +180,11 @@ The `scheduling` block supports: ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `metadata_fingerprint` - The unique fingerprint of the metadata. + +* `self_link` - The URI of the created resource. -* `name` - The name of the resource. -* `machine_type` - The type of machine. -* `zone` - The zone the machine lives in. +* `tags_fingerprint` - The unique fingerprint of the tags. diff --git a/website/source/docs/providers/google/r/compute_instance_group.html.markdown b/website/source/docs/providers/google/r/compute_instance_group.html.markdown index f7f78fb3862b..ae889e13b44b 100644 --- a/website/source/docs/providers/google/r/compute_instance_group.html.markdown +++ b/website/source/docs/providers/google/r/compute_instance_group.html.markdown @@ -10,38 +10,42 @@ description: |- The Google Compute Engine Instance Group API creates and manages pools of homogeneous Compute Engine virtual machine instances from a common instance -template. For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/unmanaged-groups) +template. For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/unmanaged-groups) and [API](https://cloud.google.com/compute/docs/reference/latest/instanceGroups) ## Example Usage ### Empty instance group -``` +```js resource "google_compute_instance_group" "test" { - name = "terraform-test" - description = "Terraform test instance group" - zone = "us-central1-a" + name = "terraform-test" + description = "Terraform test instance group" + zone = "us-central1-a" } ``` ### With instances and named ports -``` +```js resource "google_compute_instance_group" "webservers" { - name = "terraform-webservers" - description = "Terraform test instance group" - instances = [ - "${google_compute_instance.test.self_link}", - "${google_compute_instance.test2.self_link}" - ] - named_port { - name = "http" - port = "8080" - } - named_port { - name = "https" - port = "8443" - } - zone = "us-central1-a" + name = "terraform-webservers" + description = "Terraform test instance group" + + instances = [ + "${google_compute_instance.test.self_link}", + "${google_compute_instance.test2.self_link}" + ] + + named_port { + name = "http" + port = "8080" + } + + named_port { + name = "https" + port = "8443" + } + + zone = "us-central1-a" } ``` @@ -50,32 +54,40 @@ resource "google_compute_instance_group" "webservers" { The following arguments are supported: * `name` - (Required) The name of the instance group. Must be 1-63 -characters long and comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). -Supported characters include lowercase letters, numbers, and hyphens. + characters long and comply with + [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). Supported characters + include lowercase letters, numbers, and hyphens. + +* `zone` - (Required) The zone that this instance group should be created in. + +- - - * `description` - (Optional) An optional textual description of the instance - group. + group. -* `instances` - (Optional) List of instances in the group. They should be given as - self_link URLs. When adding instances they must all be in the same network and - zone as the instance group. +* `instances` - (Optional) List of instances in the group. They should be given + as self_link URLs. When adding instances they must all be in the same + network and zone as the instance group. -* `named_port` - (Optional) Named ports are key:value pairs that represent a - service name and the port number that the service runs on. The key:value pairs - are simple metadata that the Load Balancing service can use. This can specified - multiple times +* `named_port` - (Optional) The named port configuration. See the section below + for details on configuration. -* `zone` - (Required) The zone that this instance group should be created in. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. The `named_port` block supports: -* `name` - The name which the port will be mapped to. -* `port` - The port number to map the name to. +* `name` - (Required) The name which the port will be mapped to. + +* `port` - (Required) The port number to map the name to. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: * `network` - The network the instance group is in. + +* `self_link` - The URI of the created resource. + * `size` - The number of instances in the group. -* `self_link` - The URL of the created resource. diff --git a/website/source/docs/providers/google/r/compute_instance_group_manager.html.markdown b/website/source/docs/providers/google/r/compute_instance_group_manager.html.markdown index 5e39221f116f..610263ac362e 100644 --- a/website/source/docs/providers/google/r/compute_instance_group_manager.html.markdown +++ b/website/source/docs/providers/google/r/compute_instance_group_manager.html.markdown @@ -10,27 +10,28 @@ description: |- The Google Compute Engine Instance Group Manager API creates and manages pools of homogeneous Compute Engine virtual machine instances from a common instance -template. For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/manager) +template. For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/manager) and [API](https://cloud.google.com/compute/docs/instance-groups/manager/v1beta2/instanceGroupManagers) ## Example Usage -``` +```js resource "google_compute_instance_group_manager" "foobar" { - description = "Terraform test instance group manager" - name = "terraform-test" - instance_template = "${google_compute_instance_template.foobar.self_link}" - update_strategy= "NONE" - target_pools = ["${google_compute_target_pool.foobar.self_link}"] - base_instance_name = "foobar" - zone = "us-central1-a" - target_size = 2 - - named_port { - name = "customHTTP" - port = 8888 - } + name = "terraform-test" + description = "Terraform test instance group manager" + + base_instance_name = "foobar" + instance_template = "${google_compute_instance_template.foobar.self_link}" + update_strategy = "NONE" + zone = "us-central1-a" + target_pools = ["${google_compute_target_pool.foobar.self_link}"] + target_size = 2 + + named_port { + name = "customHTTP" + port = 8888 + } } ``` @@ -39,35 +40,47 @@ resource "google_compute_instance_group_manager" "foobar" { The following arguments are supported: * `base_instance_name` - (Required) The base instance name to use for -instances in this group. The value must be a valid [RFC1035](https://www.ietf.org/rfc/rfc1035.txt) name. -Supported characters are lowercase letters, numbers, and hyphens (-). Instances -are named by appending a hyphen and a random four-character string to the base -instance name. + instances in this group. The value must be a valid + [RFC1035](https://www.ietf.org/rfc/rfc1035.txt) name. Supported characters + are lowercase letters, numbers, and hyphens (-). Instances are named by + appending a hyphen and a random four-character string to the base instance + name. + +* `instance_template` - (Required) The full URL to an instance template from + which all new instances will be created. + +* `name` - (Required) The name of the instance group manager. Must be 1-63 + characters long and comply with + [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). Supported characters + include lowercase letters, numbers, and hyphens. + +* `zone` - (Required) The zone that instances in this group should be created + in. + +- - - * `description` - (Optional) An optional textual description of the instance -group manager. + group manager. -* `instance_template` - (Required) The full URL to an instance template from -which all new instances will be created. +* `named_port` - (Optional) The named port configuration. See the section below + for details on configuration. -* `update_strategy` - (Optional, Default `"RESTART"`) If the `instance_template` resource is -modified, a value of `"NONE"` will prevent any of the managed instances from -being restarted by Terraform. A value of `"RESTART"` will restart all of the -instances at once. In the future, as the GCE API matures we will support -`"ROLLING_UPDATE"` as well. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -* `name` - (Required) The name of the instance group manager. Must be 1-63 -characters long and comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). -Supported characters include lowercase letters, numbers, and hyphens. +* `update_strategy` - (Optional, Default `"RESTART"`) If the `instance_template` + resource is modified, a value of `"NONE"` will prevent any of the managed + instances from being restarted by Terraform. A value of `"RESTART"` will + restart all of the instances at once. In the future, as the GCE API matures + we will support `"ROLLING_UPDATE"` as well. -* `target_size` - (Optional) If not given at creation time, this defaults to 1. Do not specify this - if you are managing the group with an autoscaler, as this will cause fighting. +* `target_size` - (Optional) If not given at creation time, this defaults to 1. + Do not specify this if you are managing the group with an autoscaler, as + this will cause fighting. * `target_pools` - (Optional) The full URL of all target pools to which new -instances in the group are added. Updating the target pools attribute does not -affect existing instances. - -* `zone` - (Required) The zone that instances in this group should be created in. + instances in the group are added. Updating the target pools attribute does + not affect existing instances. The `named_port` block supports: (Include a `named_port` block for each named-port required). @@ -77,7 +90,10 @@ The `named_port` block supports: (Include a `named_port` block for each named-po ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `fingerprint` - The fingerprint of the instance group manager. * `instance_group` - The full URL of the instance group created by the manager. diff --git a/website/source/docs/providers/google/r/compute_instance_template.html.markdown b/website/source/docs/providers/google/r/compute_instance_template.html.markdown index 4aaae38c71b3..e6bc6e6b5abb 100644 --- a/website/source/docs/providers/google/r/compute_instance_template.html.markdown +++ b/website/source/docs/providers/google/r/compute_instance_template.html.markdown @@ -9,7 +9,7 @@ description: |- # google\_compute\_instance\_template -Manages a VM instance template resource within GCE. For more information see +Manages a VM instance template resource within GCE. For more information see [the official documentation](https://cloud.google.com/compute/docs/instance-templates) and [API](https://cloud.google.com/compute/docs/reference/latest/instanceTemplates). @@ -17,42 +17,44 @@ and ## Example Usage -``` +```js resource "google_compute_instance_template" "foobar" { - name = "terraform-test" - description = "template description" - instance_description = "description assigned to instances" - machine_type = "n1-standard-1" - can_ip_forward = false - automatic_restart = true - on_host_maintenance = "MIGRATE" - tags = ["foo", "bar"] - - # Create a new boot disk from an image - disk { - source_image = "debian-7-wheezy-v20160301" - auto_delete = true - boot = true - } - - # Use an existing disk resource - disk { - source = "foo_existing_disk" - auto_delete = false - boot = false - } - - network_interface { - network = "default" - } - - metadata { - foo = "bar" - } - - service_account { - scopes = ["userinfo-email", "compute-ro", "storage-ro"] - } + name = "terraform-test" + description = "template description" + + tags = ["foo", "bar"] + + instance_description = "description assigned to instances" + machine_type = "n1-standard-1" + can_ip_forward = false + automatic_restart = true + on_host_maintenance = "MIGRATE" + + // Create a new boot disk from an image + disk { + source_image = "debian-7-wheezy-v20160301" + auto_delete = true + boot = true + } + + // Use an existing disk resource + disk { + source = "foo_existing_disk" + auto_delete = false + boot = false + } + + network_interface { + network = "default" + } + + metadata { + foo = "bar" + } + + service_account { + scopes = ["userinfo-email", "compute-ro", "storage-ro"] + } } ``` @@ -62,128 +64,130 @@ Note that changing any field for this resource forces a new resource to be creat The following arguments are supported: +* `disk` - (Required) Disks to attach to instances created from this template. + This can be specified multiple times for multiple disks. Structure is + documented below. + +* `machine_type` - (Required) The machine type to create. + * `name` - (Required) A unique name for the resource, required by GCE. -* `description` - (Optional) A brief description of this resource. +- - - * `can_ip_forward` - (Optional) Whether to allow sending and receiving of - packets with non-matching source or destination IPs. - This defaults to false. - -* `instance_description` - (Optional) A brief description to use for instances - created from this template. + packets with non-matching source or destination IPs. This defaults to false. -* `machine_type` - (Required) The machine type to create. +* `description` - (Optional) A brief description of this resource. -* `disk` - (Required) Disks to attach to instances created from this - template. This can be specified multiple times for multiple disks. - Structure is documented below. +* `instance_description` - (Optional) A brief description to use for instances + created from this template. * `metadata` - (Optional) Metadata key/value pairs to make available from - within instances created from this template. + within instances created from this template. -* `network_interface` - (Required) Networks to attach to instances created from this template. - This can be specified multiple times for multiple networks. Structure is - documented below. +* `network_interface` - (Required) Networks to attach to instances created from + this template. This can be specified multiple times for multiple networks. + Structure is documented below. -* `region` - (Optional) An instance template is a global resource that is not bound to a zone - or a region. However, you can still specify some regional resources in an instance template, - which restricts the template to the region where that resource resides. For example, a - custom `subnetwork` resource is tied to a specific region. - Defaults to the region of the Provider if no value is given. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -* `automatic_restart` - (Optional, Deprecated - see `scheduling`) - Specifies whether the instance should be - automatically restarted if it is terminated by Compute Engine (not - terminated by a user). - This defaults to true. +* `region` - (Optional) An instance template is a global resource that is not + bound to a zone or a region. However, you can still specify some regional + resources in an instance template, which restricts the template to the + region where that resource resides. For example, a custom `subnetwork` + resource is tied to a specific region. Defaults to the region of the + Provider if no value is given. -* `on_host_maintenance` - (Optional, Deprecated - see `scheduling`) - Defines the maintenance behavior for this instance. +* `scheduling` - (Optional) The scheduling strategy to use. More details about + this configuration option are detailed below. * `service_account` - (Optional) Service account to attach to the instance. * `tags` - (Optional) Tags to attach to the instance. - - The `disk` block supports: * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. - This defaults to true. + This defaults to true. * `boot` - (Optional) Indicates that this is a boot disk. -* `device_name` - (Optional) A unique device name that is reflected into - the /dev/ tree of a Linux operating system running within the instance. - If not specified, the server chooses a default device name to apply to - this disk. +* `device_name` - (Optional) A unique device name that is reflected into the + /dev/ tree of a Linux operating system running within the instance. If not + specified, the server chooses a default device name to apply to this disk. * `disk_name` - (Optional) Name of the disk. When not provided, this defaults - to the name of the instance. + to the name of the instance. * `source_image` - (Required if source not set) The name of the image to base - this disk off of. + this disk off of. * `interface` - (Optional) Specifies the disk interface to use for attaching - this disk. + this disk. * `mode` - (Optional) The mode in which to attach this disk, either READ_WRITE - or READ_ONLY. If you are attaching or creating a boot disk, this must - read-write mode. + or READ_ONLY. If you are attaching or creating a boot disk, this must + read-write mode. * `source` - (Required if source_image not set) The name of the disk (such as - those managed by `google_compute_disk`) to attach. + those managed by `google_compute_disk`) to attach. * `disk_type` - (Optional) The GCE disk type. Can be either `"pd-ssd"`, - `"local-ssd"`, or `"pd-standard"`. + `"local-ssd"`, or `"pd-standard"`. -* `disk_size_gb` - (Optional) The size of the image in gigabytes. If not specified, - it will inherit the size of its base image. +* `disk_size_gb` - (Optional) The size of the image in gigabytes. If not + specified, it will inherit the size of its base image. * `type` - (Optional) The type of GCE disk, can be either `"SCRATCH"` or - `"PERSISTENT"`. + `"PERSISTENT"`. The `network_interface` block supports: -* `network` - (Optional) The name of the network to attach this interface to. Use `network` - attribute for Legacy or Auto subnetted networks and `subnetwork` for custom subnetted - networks. +* `network` - (Optional) The name of the network to attach this interface to. + Use `network` attribute for Legacy or Auto subnetted networks and + `subnetwork` for custom subnetted networks. -* `subnetwork` - (Optional) the name of the subnetwork to attach this interface to. The subnetwork - must exist in the same `region` this instance will be created in. Either `network` - or `subnetwork` must be provided. +* `subnetwork` - (Optional) the name of the subnetwork to attach this interface + to. The subnetwork must exist in the same `region` this instance will be + created in. Either `network` or `subnetwork` must be provided. -* `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be - accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet -(this means that ssh provisioners will not work unless you are running Terraform can send traffic to -the instance's network (e.g. via tunnel or because it is running on another cloud instance on that -network). This block can be repeated multiple times. Structure documented below. +* `access_config` - (Optional) Access configurations, i.e. IPs via which this + instance can be accessed via the Internet. Omit to ensure that the instance + is not accessible from the Internet (this means that ssh provisioners will + not work unless you are running Terraform can send traffic to the instance's + network (e.g. via tunnel or because it is running on another cloud instance + on that network). This block can be repeated multiple times. Structure documented below. The `access_config` block supports: -* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip. If not - given, one will be generated. +* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's + network ip. If not given, one will be generated. The `service_account` block supports: * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud - short names are supported. + short names are supported. The `scheduling` block supports: * `automatic_restart` - (Optional) Specifies whether the instance should be - automatically restarted if it is terminated by Compute Engine (not - terminated by a user). - This defaults to true. + automatically restarted if it is terminated by Compute Engine (not + terminated by a user). This defaults to true. -* `on_host_maintenance` - (Optional) Defines the maintenance behavior for this instance. +* `on_host_maintenance` - (Optional) Defines the maintenance behavior for this + instance. -* `preemptible` - (Optional) Allows instance to be preempted. Read - more on this [here](https://cloud.google.com/compute/docs/instances/preemptible). +* `preemptible` - (Optional) Allows instance to be preempted. Read more on this + [here](https://cloud.google.com/compute/docs/instances/preemptible). ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `metadata_fingerprint` - The unique fingerprint of the metadata. + +* `self_link` - The URI of the created resource. -* `self_link` - The URL of the created resource. +* `tags_fingerprint` - The unique fingerprint of the tags. diff --git a/website/source/docs/providers/google/r/compute_network.html.markdown b/website/source/docs/providers/google/r/compute_network.html.markdown index 843fd8839489..25bedbb5fc7d 100644 --- a/website/source/docs/providers/google/r/compute_network.html.markdown +++ b/website/source/docs/providers/google/r/compute_network.html.markdown @@ -12,10 +12,10 @@ Manages a network within GCE. ## Example Usage -``` +```js resource "google_compute_network" "default" { - name = "test" - ipv4_range = "10.0.0.0/16" + name = "test" + ipv4_range = "10.0.0.0/16" } ``` @@ -26,23 +26,31 @@ The following arguments are supported: * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -* `ipv4_range` - (Optional) The IPv4 address range that machines in this - network are assigned to, represented as a CIDR block. If not - set, an auto or custom subnetted network will be created, depending - on the value of `auto_create_subnetworks` attribute. This attribute - may not be used if `auto_create_subnets` is specified. +- - - + +* `auto_create_subnetworks` - (Optional) If set to true, this network will be + created in auto subnet mode, and Google will create a subnet for each region + automatically. If set to false, and `ipv4_range` is not set, a custom + subnetted network will be created that can support + `google_compute_subnetwork` resources. This attribute may not be used if + `ipv4_range` is specified. + +* `description` - (Optional) A brief description of this resource. -* `auto_create_subnetworks` - (Optional) If set to true, this network - will be created in auto subnet mode, and Google will create a - subnet for each region automatically. - If set to false, and `ipv4_range` is not set, a custom subnetted - network will be created that can support `google_compute_subnetwork` - resources. This attribute may not be used if `ipv4_range` is specified. +* `ipv4_range` - (Optional) The IPv4 address range that machines in this network + are assigned to, represented as a CIDR block. If not set, an auto or custom + subnetted network will be created, depending on the value of + `auto_create_subnetworks` attribute. This attribute may not be used if + `auto_create_subnets` is specified. This attribute is deprecated. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `ipv4_range` - The CIDR block of this network. * `gateway_ipv4` - The IPv4 address of the gateway. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_project_metadata.html.markdown b/website/source/docs/providers/google/r/compute_project_metadata.html.markdown index 286455db8d1a..d1f1652a37c7 100644 --- a/website/source/docs/providers/google/r/compute_project_metadata.html.markdown +++ b/website/source/docs/providers/google/r/compute_project_metadata.html.markdown @@ -12,13 +12,13 @@ Manages metadata common to all instances for a project in GCE. ## Example Usage -``` +```js resource "google_compute_project_metadata" "default" { - metadata { - foo = "bar" - fizz = "buzz" - 13 = "42" - } + metadata { + foo = "bar" + fizz = "buzz" + 13 = "42" + } } ``` @@ -26,11 +26,14 @@ resource "google_compute_project_metadata" "default" { The following arguments are supported: -* `metadata` - (Required) A series of key value pairs. Changing this resource updates - the GCE state. +* `metadata` - (Required) A series of key value pairs. Changing this resource + updates the GCE state. -## Attributes Reference +- - - -The following attributes are exported: +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +## Attributes Reference -* `metadata` - Common instance metadata. +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/compute_route.html.markdown b/website/source/docs/providers/google/r/compute_route.html.markdown index 9ed18ef5e819..0d99fe30dc7b 100644 --- a/website/source/docs/providers/google/r/compute_route.html.markdown +++ b/website/source/docs/providers/google/r/compute_route.html.markdown @@ -12,18 +12,18 @@ Manages a network route within GCE. ## Example Usage -``` +```js resource "google_compute_network" "foobar" { - name = "test" - ipv4_range = "10.0.0.0/16" + name = "test" + ipv4_range = "10.0.0.0/16" } resource "google_compute_route" "foobar" { - name = "test" - dest_range = "15.0.0.0/24" - network = "${google_compute_network.foobar.name}" - next_hop_ip = "10.0.1.5" - priority = 100 + name = "test" + dest_range = "15.0.0.0/24" + network = "${google_compute_network.foobar.name}" + next_hop_ip = "10.0.1.5" + priority = 100 } ``` @@ -31,44 +31,43 @@ resource "google_compute_route" "foobar" { The following arguments are supported: +* `dest_range` - (Required) The destination IPv4 address range that this + route applies to. + * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -* `dest_range` - (Required) The destination IPv4 address range that this - route applies to. - * `network` - (Required) The name of the network to attach this route to. -* `next_hop_ip` - (Optional) The IP address of the next hop if this route - is matched. +* `priority` - (Required) The priority of this route, used to break ties. + +- - - + +* `next_hop_gateway` - (Optional) The name of the internet gateway to route + to if this route is matched. * `next_hop_instance` - (Optional) The name of the VM instance to route to if this route is matched. -* `next_hop_instance_zone` - (Required when `next_hop_instance` is specified) The zone of the instance specified - in `next_hop_instance`. +* `next_hop_instance_zone` - (Required when `next_hop_instance` is specified) + The zone of the instance specified in `next_hop_instance`. -* `next_hop_gateway` - (Optional) The name of the internet gateway to route - to if this route is matched. +* `next_hop_ip` - (Optional) The IP address of the next hop if this route + is matched. -* `next_hop_vpn_gateway` - (Optional) The name of the VPN to route to if this +* `next_hop_vpn_tunnel` - (Optional) The name of the VPN to route to if this route is matched. -* `priority` - (Required) The priority of this route, used to break ties. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. * `tags` - (Optional) The tags that this route applies to. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `dest_range` - The destination CIDR block of this route. -* `network` - The name of the network of this route. -* `next_hop_ip` - The IP address of the next hop, if available. -* `next_hop_instance` - The name of the instance of the next hop, if available. -* `next_hop_instance_zone` - The zone of the next hop instance, if available. -* `next_hop_gateway` - The name of the next hop gateway, if available. * `next_hop_network` - The name of the next hop network, if available. -* `priority` - The priority of this route. -* `tags` - The tags this route applies to. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_ssl_certificate.html.markdown b/website/source/docs/providers/google/r/compute_ssl_certificate.html.markdown index 3d705ee16f98..1c306a425f66 100644 --- a/website/source/docs/providers/google/r/compute_ssl_certificate.html.markdown +++ b/website/source/docs/providers/google/r/compute_ssl_certificate.html.markdown @@ -16,12 +16,12 @@ For more information see ## Example Usage -``` +```js resource "google_compute_ssl_certificate" "default" { - name = "my-certificate" - description = "a description" - private_key = "${file("path/to/private.key")}" - certificate = "${file("path/to/certificate.crt")}" + name = "my-certificate" + description = "a description" + private_key = "${file("path/to/private.key")}" + certificate = "${file("path/to/certificate.crt")}" } ``` @@ -29,19 +29,29 @@ resource "google_compute_ssl_certificate" "default" { The following arguments are supported: +* `certificate` - (Required) A local certificate file in PEM format. The chain + may be at most 5 certs long, and must include at least one intermediate + cert. Changing this forces a new resource to be created. + * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -* `description` - (Optional) An optional description of this resource. - Changing this forces a new resource to be created. + * `private_key` - (Required) Write only private key in PEM format. Changing this forces a new resource to be created. -* `certificate` - (Required) A local certificate file in PEM format. The chain - may be at most 5 certs long, and must include at least one intermediate cert. + +- - - + +* `description` - (Optional) An optional description of this resource. Changing this forces a new resource to be created. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `id` - A unique ID for the certificated, assigned by GCE. * `self_link` - The URI of the created resource. -* `id` - A unique ID assigned by GCE. diff --git a/website/source/docs/providers/google/r/compute_subnetwork.html.markdown b/website/source/docs/providers/google/r/compute_subnetwork.html.markdown index 6394638f1510..d95e43f3bc65 100644 --- a/website/source/docs/providers/google/r/compute_subnetwork.html.markdown +++ b/website/source/docs/providers/google/r/compute_subnetwork.html.markdown @@ -12,12 +12,12 @@ Manages a subnetwork within GCE. ## Example Usage -``` +```js resource "google_compute_subnetwork" "default-us-east1" { - name = "default-us-east1" - ip_cidr_range = "10.0.0.0/16" - network = "${google_compute_network.default.self_link}" - region = "us-east1" + name = "default-us-east1" + ip_cidr_range = "10.0.0.0/16" + network = "${google_compute_network.default.self_link}" + region = "us-east1" } ``` @@ -25,23 +25,30 @@ resource "google_compute_subnetwork" "default-us-east1" { The following arguments are supported: +* `ip_cidr_range` - (Required) The IP address range that machines in this + network are assigned to, represented as a CIDR block. + * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. * `network` - (Required) A link to the parent network of this subnetwork. - The parent network must have been created in custom subnet mode. - -* `ip_cidr_range` - (Required) The IP address range that machines in this - network are assigned to, represented as a CIDR block. + The parent network must have been created in custom subnet mode. -* `region` - (Required) The region this subnetwork will be created in. +- - - * `description` - (Optional) Description of this subnetwork. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `region` - (Optional) The region this subnetwork will be created in. If + unspecified, this defaults to the region configured in the provider. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `ip_cidr_range` - The CIDR block of this network. * `gateway_address` - The IP address of the gateway. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_target_http_proxy.html.markdown b/website/source/docs/providers/google/r/compute_target_http_proxy.html.markdown index c0199fd38210..3b36f4144d5a 100644 --- a/website/source/docs/providers/google/r/compute_target_http_proxy.html.markdown +++ b/website/source/docs/providers/google/r/compute_target_http_proxy.html.markdown @@ -16,48 +16,49 @@ documentation](https://cloud.google.com/compute/docs/load-balancing/http/target- ## Example Usage -``` +```js resource "google_compute_target_http_proxy" "default" { - name = "test-proxy" - description = "a description" - url_map = "${google_compute_url_map.default.self_link}" + name = "test-proxy" + description = "a description" + url_map = "${google_compute_url_map.default.self_link}" } resource "google_compute_url_map" "default" { - name = "url-map" - description = "a description" - default_service = "${google_compute_backend_service.default.self_link}" + name = "url-map" + description = "a description" - host_rule { - hosts = ["mysite.com"] - path_matcher = "allpaths" - } + default_service = "${google_compute_backend_service.default.self_link}" + + host_rule { + hosts = ["mysite.com"] + path_matcher = "allpaths" + } - path_matcher { - default_service = "${google_compute_backend_service.default.self_link}" - name = "allpaths" - path_rule { - paths = ["/*"] - service = "${google_compute_backend_service.default.self_link}" - } + path_matcher { + name = "allpaths" + default_service = "${google_compute_backend_service.default.self_link}" + + path_rule { + paths = ["/*"] + service = "${google_compute_backend_service.default.self_link}" } + } } resource "google_compute_backend_service" "default" { - name = "default-backend" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" + name = "default-backend" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 - health_checks = ["${google_compute_http_health_check.default.self_link}"] + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 } ``` @@ -65,16 +66,23 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. -* `description` - (Optional) A description of this resource. - Changing this forces a new resource to be created. -* `url_map` - (Required) The URL of a URL Map resource that defines the - mapping from the URL to the BackendService. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. + +* `url_map` - (Required) The URL of a URL Map resource that defines the mapping + from the URL to the BackendService. + +- - - + +* `description` - (Optional) A description of this resource. Changing this + forces a new resource to be created. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `self_link` - The URI of the created resource. * `id` - A unique ID assigned by GCE. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_target_https_proxy.html.markdown b/website/source/docs/providers/google/r/compute_target_https_proxy.html.markdown index d678242d5b0c..5f3d82d1e993 100644 --- a/website/source/docs/providers/google/r/compute_target_https_proxy.html.markdown +++ b/website/source/docs/providers/google/r/compute_target_https_proxy.html.markdown @@ -16,56 +16,57 @@ documentation](https://cloud.google.com/compute/docs/load-balancing/http/target- ## Example Usage -``` +```js resource "google_compute_target_https_proxy" "default" { - name = "test-proxy" - description = "a description" - url_map = "${google_compute_url_map.default.self_link}" - ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"] + name = "test-proxy" + description = "a description" + url_map = "${google_compute_url_map.default.self_link}" + ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"] } resource "google_compute_ssl_certificate" "default" { - name = "my-certificate" - description = "a description" - private_key = "${file("path/to/private.key")}" - certificate = "${file("path/to/certificate.crt")}" + name = "my-certificate" + description = "a description" + private_key = "${file("path/to/private.key")}" + certificate = "${file("path/to/certificate.crt")}" } resource "google_compute_url_map" "default" { - name = "url-map" - description = "a description" - default_service = "${google_compute_backend_service.default.self_link}" + name = "url-map" + description = "a description" - host_rule { - hosts = ["mysite.com"] - path_matcher = "allpaths" - } + default_service = "${google_compute_backend_service.default.self_link}" + + host_rule { + hosts = ["mysite.com"] + path_matcher = "allpaths" + } - path_matcher { - default_service = "${google_compute_backend_service.default.self_link}" - name = "allpaths" - path_rule { - paths = ["/*"] - service = "${google_compute_backend_service.default.self_link}" - } + path_matcher { + name = "allpaths" + default_service = "${google_compute_backend_service.default.self_link}" + + path_rule { + paths = ["/*"] + service = "${google_compute_backend_service.default.self_link}" } + } } resource "google_compute_backend_service" "default" { - name = "default-backend" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" + name = "default-backend" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 - health_checks = ["${google_compute_http_health_check.default.self_link}"] + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 } ``` @@ -73,19 +74,29 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. -* `description` - (Optional) A description of this resource. - Changing this forces a new resource to be created. -* `url_map` - (Required) The URL of a URL Map resource that defines the - mapping from the URL to the BackendService. -* `ssl_certificates` - (Required) The URLs of the SSL Certificate resources - that authenticate connections between users and load balancing. Currently - exactly one must be specified. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. + +* `ssl_certificates` - (Required) The URLs of the SSL Certificate resources that + authenticate connections between users and load balancing. Currently exactly + one must be specified. + +* `url_map` - (Required) The URL of a URL Map resource that defines the mapping + from the URL to the BackendService. + +- - - + +* `description` - (Optional) A description of this resource. Changing this + forces a new resource to be created. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `self_link` - The URI of the created resource. * `id` - A unique ID assigned by GCE. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_target_pool.html.markdown b/website/source/docs/providers/google/r/compute_target_pool.html.markdown index 6857bc0cb976..0192c7a72e15 100644 --- a/website/source/docs/providers/google/r/compute_target_pool.html.markdown +++ b/website/source/docs/providers/google/r/compute_target_pool.html.markdown @@ -8,8 +8,8 @@ description: |- # google\_compute\_target\_pool -Manages a Target Pool within GCE. This is a collection of instances used as -target of a network load balancer (Forwarding Rule). For more information see +Manages a Target Pool within GCE. This is a collection of instances used as +target of a network load balancer (Forwarding Rule). For more information see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/network/target-pools) and [API](https://cloud.google.com/compute/docs/reference/latest/targetPools). @@ -17,11 +17,18 @@ and [API](https://cloud.google.com/compute/docs/reference/latest/targetPools). ## Example Usage -``` +```js resource "google_compute_target_pool" "default" { - name = "test" - instances = [ "us-central1-a/myinstance1", "us-central1-b/myinstance2" ] - health_checks = [ "${google_compute_http_health_check.default.name}" ] + name = "test" + + instances = [ + "us-central1-a/myinstance1", + "us-central1-b/myinstance2", + ] + + health_checks = [ + "${google_compute_http_health_check.default.name}", + ] } ``` @@ -29,31 +36,40 @@ resource "google_compute_target_pool" "default" { The following arguments are supported: -* `backup_pool` - (Optional) URL to the backup target pool. Must also set - failover\_ratio. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. + +- - - + +* `backup_pool` - (Optional) URL to the backup target pool. Must also set + failover\_ratio. * `description` - (Optional) Textual description field. * `failover_ratio` - (Optional) Ratio (0 to 1) of failed nodes before using the - backup pool (which must also be set). + backup pool (which must also be set). * `health_checks` - (Optional) List of zero or one healthcheck names. -* `instances` - (Optional) List of instances in the pool. They can be given as - URLs, or in the form of "zone/name". Note that the instances need not exist - at the time of target pool creation, so there is no need to use the Terraform - interpolators to create a dependency on the instances from the target pool. +* `instances` - (Optional) List of instances in the pool. They can be given as + URLs, or in the form of "zone/name". Note that the instances need not exist + at the time of target pool creation, so there is no need to use the + Terraform interpolators to create a dependency on the instances from the + target pool. -* `name` - (Required) A unique name for the resource, required by GCE. Changing - this forces a new resource to be created. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -* `session_affinity` - (Optional) How to distribute load. Options are "NONE" (no affinity). "CLIENT\_IP" (hash of the source/dest addresses / ports), and "CLIENT\_IP\_PROTO" also includes the protocol (default "NONE"). +* `region` - (Optional) Where the target pool resides. Defaults to project + region. -* `region` - (Optional) Where the target pool resides. Defaults to project region. +* `session_affinity` - (Optional) How to distribute load. Options are "NONE" (no + affinity). "CLIENT\_IP" (hash of the source/dest addresses / ports), and + "CLIENT\_IP\_PROTO" also includes the protocol (default "NONE"). ## Attributes Reference -The following attributes are exported: - -* `self_link` - The URL of the created resource. +In addition to the arguments listed above, the following computed attributes are +exported: +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_url_map.html.markdown b/website/source/docs/providers/google/r/compute_url_map.html.markdown index 37b9da909ab9..c3e127963aaa 100644 --- a/website/source/docs/providers/google/r/compute_url_map.html.markdown +++ b/website/source/docs/providers/google/r/compute_url_map.html.markdown @@ -1,14 +1,14 @@ --- layout: "google" page_title: "Google: google_compute_url_map" -sidebar_current: "docs-google-resource-url-map" +sidebar_current: "docs-google-compute-url-map" description: |- Manages a URL Map resource in GCE. --- # google\_compute\_url\_map -Manages a URL Map resource within GCE. For more information see +Manages a URL Map resource within GCE. For more information see [the official documentation](https://cloud.google.com/compute/docs/load-balancing/http/url-map) and [API](https://cloud.google.com/compute/docs/reference/latest/urlMaps). @@ -16,63 +16,65 @@ and ## Example Usage -``` +```js resource "google_compute_url_map" "foobar" { - name = "urlmap" - description = "a description" + name = "urlmap" + description = "a description" + + default_service = "${google_compute_backend_service.home.self_link}" + + host_rule { + hosts = ["mysite.com"] + path_matcher = "allpaths" + } + + path_matcher { + name = "allpaths" default_service = "${google_compute_backend_service.home.self_link}" - host_rule { - hosts = ["mysite.com"] - path_matcher = "allpaths" + path_rule { + paths = ["/home"] + service = "${google_compute_backend_service.home.self_link}" } - path_matcher { - default_service = "${google_compute_backend_service.home.self_link}" - name = "allpaths" - path_rule { - paths = ["/home"] - service = "${google_compute_backend_service.home.self_link}" - } - - path_rule { - paths = ["/login"] - service = "${google_compute_backend_service.login.self_link}" - } + path_rule { + paths = ["/login"] + service = "${google_compute_backend_service.login.self_link}" } + } - test { - service = "${google_compute_backend_service.home.self_link}" - host = "hi.com" - path = "/home" - } + test { + service = "${google_compute_backend_service.home.self_link}" + host = "hi.com" + path = "/home" + } } resource "google_compute_backend_service" "login" { - name = "login-backend" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" + name = "login-backend" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 + region = "us-central1" - health_checks = ["${google_compute_http_health_check.default.self_link}"] + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_backend_service" "home" { - name = "home-backend" - port_name = "http" - protocol = "HTTP" - timeout_sec = 10 - region = "us-central1" + name = "home-backend" + port_name = "http" + protocol = "HTTP" + timeout_sec = 10 + region = "us-central1" - health_checks = ["${google_compute_http_health_check.default.self_link}"] + health_checks = ["${google_compute_http_health_check.default.self_link}"] } resource "google_compute_http_health_check" "default" { - name = "test" - request_path = "/" - check_interval_sec = 1 - timeout_sec = 1 + name = "test" + request_path = "/" + check_interval_sec = 1 + timeout_sec = 1 } ``` @@ -80,50 +82,62 @@ resource "google_compute_http_health_check" "default" { The following arguments are supported: +* `default_service` - (Required) The URL of the backend service to use when none + of the given rules match. See the documentation for formatting the service + URL + [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#defaultService) + * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. +- - - + * `description` - (Optional) A brief description of this resource. -* `default_service` - (Required) The URL of the backend service to use when none of the - given rules match. See the documentation for formatting the service URL - [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#defaultService) +* `host_rule` - (Optional) A list of host rules. See below for configuration + options. + +* `path_matcher` - (Optional) A list of paths to match. See below for + configuration options. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -The `host_rule` block supports: (Note that this block can be defined an arbitrary -number of times.) +* `test` - (Optional) The test to perform. See below for configuration options. -* `hosts` (Required) - A list of hosts to match against. See the documention - for formatting each host [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#hostRules.hosts) +The `host_rule` block supports: (This block can be defined multiple times). + +* `hosts` (Required) - A list of hosts to match against. See the documentation + for formatting each host + [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#hostRules.hosts) * `description` - (Optional) An optional description of the host rule. * `path_matcher` - (Required) The name of the `path_matcher` (defined below) to apply this host rule to. -The `path_matcher` block supports: (Note that this block can be defined an arbitrary -number of times.) +The `path_matcher` block supports: (This block can be defined multiple times) * `default_service` - (Required) The URL for the backend service to use if none - of the given paths match. See the documentation for formatting the service URL - [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService) + of the given paths match. See the documentation for formatting the service + URL [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService) -* `name` - (Required) The name of the `path_matcher` resource. Used by the `host_rule` - block above. +* `name` - (Required) The name of the `path_matcher` resource. Used by the + `host_rule` block above. * `description` - (Optional) An optional description of the host rule. -The `path_matcher.path_rule` sub-block supports: (Note that this block can be defined an arbitrary -number of times.) +The `path_matcher.path_rule` sub-block supports: (This block can be defined +multiple times) * `paths` - (Required) The list of paths to match against. See the documentation for formatting these [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatchers.pathRules.paths) * `default_service` - (Required) The URL for the backend service to use if any - of the given paths match. See the documentation for formatting the service URL - [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService) + of the given paths match. See the documentation for formatting the service + URL [here](https://cloud.google.com/compute/docs/reference/latest/urlMaps#pathMatcher.defaultService) -The optional `test` block supports: (Note that this block can be defined an arbitary -number of times.) +The optional `test` block supports: (This block can be defined multiple times) * `service` - (Required) The service that should be matched by this test. @@ -135,7 +149,11 @@ number of times.) ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: + +* `fingerprint` - The unique fingerprint for this resource. * `id` - The GCE assigned ID of the resource. -* `self_link` - A GCE assigned link to the resource. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_vpn_gateway.html.markdown b/website/source/docs/providers/google/r/compute_vpn_gateway.html.markdown index a70e7d22c44d..bca0f9fc01a7 100644 --- a/website/source/docs/providers/google/r/compute_vpn_gateway.html.markdown +++ b/website/source/docs/providers/google/r/compute_vpn_gateway.html.markdown @@ -14,83 +14,91 @@ Manages a VPN Gateway in the GCE network. For more info, read the ## Example Usage -``` +```js resource "google_compute_network" "network1" { - name = "network1" - ipv4_range = "10.120.0.0/16" + name = "network1" + ipv4_range = "10.120.0.0/16" } resource "google_compute_vpn_gateway" "target_gateway" { - name = "vpn1" - network = "${google_compute_network.network1.self_link}" - region = "${var.region}" + name = "vpn1" + network = "${google_compute_network.network1.self_link}" + region = "${var.region}" } resource "google_compute_address" "vpn_static_ip" { - name = "vpn-static-ip" - region = "${var.region}" + name = "vpn-static-ip" + region = "${var.region}" } resource "google_compute_forwarding_rule" "fr_esp" { - name = "fr-esp" - region = "${var.region}" - ip_protocol = "ESP" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-esp" + region = "${var.region}" + ip_protocol = "ESP" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_forwarding_rule" "fr_udp500" { - name = "fr-udp500" - region = "${var.region}" - ip_protocol = "UDP" - port_range = "500" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-udp500" + region = "${var.region}" + ip_protocol = "UDP" + port_range = "500" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_forwarding_rule" "fr_udp4500" { - name = "fr-udp4500" - region = "${var.region}" - ip_protocol = "UDP" - port_range = "4500" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-udp4500" + region = "${var.region}" + ip_protocol = "UDP" + port_range = "4500" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_vpn_tunnel" "tunnel1" { - name = "tunnel1" - region = "${var.region}" - peer_ip = "15.0.0.120" - shared_secret = "a secret message" - target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}" - depends_on = ["google_compute_forwarding_rule.fr_esp", - "google_compute_forwarding_rule.fr_udp500", - "google_compute_forwarding_rule.fr_udp4500"] + name = "tunnel1" + region = "${var.region}" + peer_ip = "15.0.0.120" + shared_secret = "a secret message" + + target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}" + + depends_on = [ + "google_compute_forwarding_rule.fr_esp", + "google_compute_forwarding_rule.fr_udp500", + "google_compute_forwarding_rule.fr_udp4500", + ] } resource "google_compute_route" "route1" { - name = "route1" - network = "${google_compute_network.network1.name}" - next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" - dest_range = "15.0.0.0/24" - priority = 1000 -} + name = "route1" + network = "${google_compute_network.network1.name}" + dest_range = "15.0.0.0/24" + priority = 1000 + next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" +} ``` ## Argument Reference The following arguments are supported: -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. + +* `network` - (Required) A link to the network this VPN gateway is accepting + traffic for. Changing this forces a new resource to be created. + +- - - * `description` - (Optional) A description of the resource. Changing this forces a new resource to be created. -* `network` - (Required) A link to the network this VPN gateway is accepting - traffic for. - Changing this forces a new resource to be created. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. * `region` - (Optional) The region this gateway should sit in. If not specified, the project region will be used. Changing this forces a new resource to be @@ -98,6 +106,7 @@ The following arguments are supported: ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `self_link` - A GCE server assigned link to this resource. +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/compute_vpn_tunnel.html.markdown b/website/source/docs/providers/google/r/compute_vpn_tunnel.html.markdown index 8968ce208480..79aed6b65b8b 100644 --- a/website/source/docs/providers/google/r/compute_vpn_tunnel.html.markdown +++ b/website/source/docs/providers/google/r/compute_vpn_tunnel.html.markdown @@ -13,104 +13,109 @@ Manages a VPN Tunnel to the GCE network. For more info, read the ## Example Usage -``` +```js resource "google_compute_network" "network1" { - name = "network1" - ipv4_range = "10.120.0.0/16" + name = "network1" + ipv4_range = "10.120.0.0/16" } resource "google_compute_vpn_gateway" "target_gateway" { - name = "vpn1" - network = "${google_compute_network.network1.self_link}" - region = "${var.region}" + name = "vpn1" + network = "${google_compute_network.network1.self_link}" } resource "google_compute_address" "vpn_static_ip" { - name = "vpn-static-ip" - region = "${var.region}" + name = "vpn-static-ip" } resource "google_compute_forwarding_rule" "fr_esp" { - name = "fr-esp" - region = "${var.region}" - ip_protocol = "ESP" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-esp" + ip_protocol = "ESP" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_forwarding_rule" "fr_udp500" { - name = "fr-udp500" - region = "${var.region}" - ip_protocol = "UDP" - port_range = "500" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-udp500" + ip_protocol = "UDP" + port_range = "500" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_forwarding_rule" "fr_udp4500" { - name = "fr-udp4500" - region = "${var.region}" - ip_protocol = "UDP" - port_range = "4500" - ip_address = "${google_compute_address.vpn_static_ip.address}" - target = "${google_compute_vpn_gateway.target_gateway.self_link}" + name = "fr-udp4500" + ip_protocol = "UDP" + port_range = "4500" + ip_address = "${google_compute_address.vpn_static_ip.address}" + target = "${google_compute_vpn_gateway.target_gateway.self_link}" } resource "google_compute_vpn_tunnel" "tunnel1" { - name = "tunnel1" - region = "${var.region}" - peer_ip = "15.0.0.120" - shared_secret = "a secret message" - target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}" - depends_on = ["google_compute_forwarding_rule.fr_esp", - "google_compute_forwarding_rule.fr_udp500", - "google_compute_forwarding_rule.fr_udp4500"] + name = "tunnel1" + peer_ip = "15.0.0.120" + shared_secret = "a secret message" + + target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}" + + depends_on = [ + "google_compute_forwarding_rule.fr_esp", + "google_compute_forwarding_rule.fr_udp500", + "google_compute_forwarding_rule.fr_udp4500", + ] } resource "google_compute_route" "route1" { - name = "route1" - network = "${google_compute_network.network1.name}" - next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" - dest_range = "15.0.0.0/24" - priority = 1000 -} + name = "route1" + network = "${google_compute_network.network1.name}" + dest_range = "15.0.0.0/24" + priority = 1000 + next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" +} ``` ## Argument Reference The following arguments are supported: -* `name` - (Required) A unique name for the resource, required by GCE. - Changing this forces a new resource to be created. +* `name` - (Required) A unique name for the resource, required by GCE. Changing + this forces a new resource to be created. -* `description` - (Optional) A description of the resource. - Changing this forces a new resource to be created. +* `peer_ip` - (Required) The VPN gateway sitting outside of GCE. Changing this + forces a new resource to be created. -* `peer_ip` - (Required) The VPN gateway sitting outside of GCE. +* `shared_secret` - (Required) A passphrase shared between the two VPN gateways. Changing this forces a new resource to be created. -* `region` - (Optional) The region this tunnel should sit in. If not specified, - the project region will be used. Changing this forces a new resource to be - created. +* `target_vpn_gateway` - (Required) A link to the VPN gateway sitting inside + GCE. Changing this forces a new resource to be created. -* `shared_secret` - (Required) A passphrase shared between the two VPN gateways. - Changing this forces a new resource to be created. +- - - -* `target_vpn_gateway` - (Required) A link to the VPN gateway sitting inside GCE. - Changing this forces a new resource to be created. +* `description` - (Optional) A description of the resource. Changing this forces + a new resource to be created. -* `ike_version` - (Optional) Either version 1 or 2. Default is 2. - Changing this forces a new resource to be created. +* `ike_version` - (Optional) Either version 1 or 2. Default is 2. Changing this + forces a new resource to be created. -* `local_traffic_selector` - (Optional) Specifies which CIDR ranges are announced - to the VPN peer. Mandatory if the VPN gateway is attached to a custom subnetted - network. Refer to Google documentation for more information. +* `local_traffic_selector` - (Optional) Specifies which CIDR ranges are + announced to the VPN peer. Mandatory if the VPN gateway is attached to a + custom subnetted network. Refer to Google documentation for more + information. -## Attributes Reference +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. -The following attributes are exported: +* `region` - (Optional) The region this tunnel should sit in. If not specified, + the project region will be used. Changing this forces a new resource to be + created. -* `self_link` - A GCE server assigned link to this resource. +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are +exported: * `detailed_status` - Information about the status of the VPN tunnel. + +* `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/container_cluster.html.markdown b/website/source/docs/providers/google/r/container_cluster.html.markdown index 9fe63cbe24ce..c3fc3a6a388c 100644 --- a/website/source/docs/providers/google/r/container_cluster.html.markdown +++ b/website/source/docs/providers/google/r/container_cluster.html.markdown @@ -8,64 +8,95 @@ description: |- # google\_container\_cluster --> **Note:** Due to limitations of the API, all arguments except `node_version` are non-updateable (changing any will cause recreation of the whole cluster). +!> **Warning:** Due to limitations of the API, all arguments except +`node_version` are non-updateable. Changing any will cause recreation of the +whole cluster! ## Example usage -``` +```js resource "google_container_cluster" "primary" { - name = "marcellus-wallace" - zone = "us-central1-a" - initial_node_count = 3 - - master_auth { - username = "mr.yoda" - password = "adoy.rm" - } - - node_config { - oauth_scopes = [ - "https://www.googleapis.com/auth/compute", - "https://www.googleapis.com/auth/devstorage.read_only", - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" - ] - } + name = "marcellus-wallace" + zone = "us-central1-a" + initial_node_count = 3 + + master_auth { + username = "mr.yoda" + password = "adoy.rm" + } + + node_config { + oauth_scopes = [ + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/devstorage.read_only", + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring" + ] + } } ``` ## Argument Reference -* `name` - (Required) The name of the cluster, unique within the project and zone +* `initial_node_count` - (Required) The number of nodes to create in this + cluster (not including the Kubernetes master). + +* `master_auth` - (Required) The authentication information for accessing the + Kubernetes master. + +* `name` - (Required) The name of the cluster, unique within the project and + zone. + * `zone` - (Required) The zone that all resources should be created in. -* `master_auth` - (Required) The authentication information for accessing the Kubernetes master -* `initial_node_count` - (Required) The number of nodes to create in this cluster (not including the Kubernetes master) -* `description` - (Optional) Description of the cluster -* `node_version` - (Optional) The Kubernetes version on the nodes. Only valid for upgrading of existing cluster. - Defaults to latest version supported by the server. -* `cluster_ipv4_cidr` - (Optional) The IP address range of the container pods in this cluster. - Default is an automatically assigned CIDR. -* `logging_service` - (Optional) The logging service that the cluster should write logs to. - Available options include `logging.googleapis.com` and `none`. Defaults to `logging.googleapis.com` -* `monitoring_service` - (Optional) The monitoring service that the cluster should write metrics to. - Available options include `monitoring.googleapis.com` and `none`. Defaults to `monitoring.googleapis.com` -* `network` - (Optional) The name of the Google Compute Engine network to which the cluster is connected -* `node_config` - (Optional) The machine type and image to use for all nodes in this cluster + +- - - + +* `cluster_ipv4_cidr` - (Optional) The IP address range of the container pods in + this cluster. Default is an automatically assigned CIDR. + +* `description` - (Optional) Description of the cluster. + +* `logging_service` - (Optional) The logging service that the cluster should + write logs to. Available options include `logging.googleapis.com` and + `none`. Defaults to `logging.googleapis.com` + +* `monitoring_service` - (Optional) The monitoring service that the cluster + should write metrics to. Available options include + `monitoring.googleapis.com` and `none`. Defaults to + `monitoring.googleapis.com` + +* `network` - (Optional) The name of the Google Compute Engine network to which + the cluster is connected + +* `node_config` - (Optional) The machine type and image to use for all nodes in + this cluster + +* `node_version` - (Optional) The Kubernetes version on the nodes. Only valid + for upgrading of existing cluster. Defaults to latest version supported by + the server. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. **Master Auth** supports the following arguments: -* `password` - The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint -* `username` - The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint +* `password` - The password to use for HTTP basic authentication when accessing + the Kubernetes master endpoint + +* `username` - The username to use for HTTP basic authentication when accessing + the Kubernetes master endpoint **Node Config** supports the following arguments: * `machine_type` - (Optional) The name of a Google Compute Engine machine type. - Defaults to `n1-standard-1`. -* `disk_size_gb` - (Optional) Size of the disk attached to each node, specified in GB. - The smallest allowed disk size is 10GB. Defaults to 100GB. -* `oauth_scopes` - (Optional) The set of Google API scopes to be made available on all - of the node VMs under the "default" service account. The following scopes are necessary - to ensure the correct functioning of the cluster: + Defaults to `n1-standard-1`. + +* `disk_size_gb` - (Optional) Size of the disk attached to each node, specified + in GB. The smallest allowed disk size is 10GB. Defaults to 100GB. + +* `oauth_scopes` - (Optional) The set of Google API scopes to be made available + on all of the node VMs under the "default" service account. The following + scopes are necessary to ensure the correct functioning of the cluster: * `https://www.googleapis.com/auth/compute` * `https://www.googleapis.com/auth/devstorage.read_only` @@ -74,11 +105,19 @@ resource "google_container_cluster" "primary" { ## Attributes Reference +In addition to the arguments listed above, the following computed attributes are +exported: + +* `endpoint` - The IP address of this cluster's Kubernetes master + +* `instance_group_urls` - List of instance group URLs which have been assigned + to the cluster + * `master_auth.client_certificate` - Base64 encoded public certificate - used by clients to authenticate to the cluster endpoint. + used by clients to authenticate to the cluster endpoint. + * `master_auth.client_key` - Base64 encoded private key used by clients - to authenticate to the cluster endpoint + to authenticate to the cluster endpoint + * `master_auth.cluster_ca_certificate` - Base64 encoded public certificate - that is the root of trust for the cluster -* `endpoint` - The IP address of this cluster's Kubernetes master -* `instance_group_urls` - List of instance group URLs which have been assigned to the cluster + that is the root of trust for the cluster diff --git a/website/source/docs/providers/google/r/dns_managed_zone.markdown b/website/source/docs/providers/google/r/dns_managed_zone.markdown index c57d948794f4..25d227ddbe09 100644 --- a/website/source/docs/providers/google/r/dns_managed_zone.markdown +++ b/website/source/docs/providers/google/r/dns_managed_zone.markdown @@ -12,11 +12,11 @@ Manages a zone within Google Cloud DNS. ## Example Usage -``` +```js resource "google_dns_managed_zone" "prod" { - name = "prod-zone" - dns_name = "prod.mydomain.com." - description = "Production DNS zone" + name = "prod-zone" + dns_name = "prod.mydomain.com." + description = "Production DNS zone" } ``` @@ -24,19 +24,23 @@ resource "google_dns_managed_zone" "prod" { The following arguments are supported: +* `dns_name` - (Required) The DNS name of this zone, e.g. "terraform.io". + * `name` - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -* `dns_name` - (Required) The DNS name of this zone, e.g. "terraform.io". +- - - * `description` - (Optional) A textual description field. Defaults to 'Managed by Terraform'. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `name` - The name of the resource. -* `dns_name` - The DNS name of this zone. * `name_servers` - The list of nameservers that will be authoritative for this - domain. Use NS records to redirect from your DNS provider to these names, -thus making Google Cloud DNS authoritative for this zone. + domain. Use NS records to redirect from your DNS provider to these names, + thus making Google Cloud DNS authoritative for this zone. diff --git a/website/source/docs/providers/google/r/dns_record_set.markdown b/website/source/docs/providers/google/r/dns_record_set.markdown index 079ab9c36dd9..40bbec9c33e0 100644 --- a/website/source/docs/providers/google/r/dns_record_set.markdown +++ b/website/source/docs/providers/google/r/dns_record_set.markdown @@ -14,33 +14,34 @@ Manages a set of DNS records within Google Cloud DNS. This example is the common case of binding a DNS name to the ephemeral IP of a new instance: -``` +```js resource "google_compute_instance" "frontend" { - name = "frontend" - machine_type = "g1-small" - zone = "us-central1-b" - - disk { - image = "debian-7-wheezy-v20160301" - } - - network_interface { - network = "default" - access_config { - } - } + name = "frontend" + machine_type = "g1-small" + zone = "us-central1-b" + + disk { + image = "debian-7-wheezy-v20160301" + } + + network_interface { + network = "default" + access_config {} + } } resource "google_dns_managed_zone" "prod" { - name = "prod-zone" - dns_name = "prod.mydomain.com." + name = "prod-zone" + dns_name = "prod.mydomain.com." } resource "google_dns_record_set" "frontend" { - managed_zone = "${google_dns_managed_zone.prod.name}" - name = "frontend.${google_dns_managed_zone.prod.dns_name}" - type = "A" - ttl = 300 - rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.assigned_nat_ip}"] + name = "frontend.${google_dns_managed_zone.prod.dns_name}" + type = "A" + ttl = 300 + + managed_zone = "${google_dns_managed_zone.prod.name}" + + rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.assigned_nat_ip}"] } ``` @@ -48,17 +49,23 @@ resource "google_dns_record_set" "frontend" { The following arguments are supported: -* `managed_zone` - (Required) The name of the zone in which this record set will reside. +* `managed_zone` - (Required) The name of the zone in which this record set will + reside. * `name` - (Required) The DNS name this record set will apply to. -* `type` - (Required) The DNS record set type. +* `rrdatas` - (Required) The string data for the records in this record set + whose meaning depends on the DNS type. * `ttl` - (Required) The time-to-live of this record set (seconds). -* `rrdatas` - (Required) The string data for the records in this record set - whose meaning depends on the DNS type. +* `type` - (Required) The DNS record set type. + +- - - + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. ## Attributes Reference -All arguments are available as attributes. +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/pubsub_subscription.html.markdown b/website/source/docs/providers/google/r/pubsub_subscription.html.markdown index 7917205364ea..e2b4ccaa6d12 100644 --- a/website/source/docs/providers/google/r/pubsub_subscription.html.markdown +++ b/website/source/docs/providers/google/r/pubsub_subscription.html.markdown @@ -8,24 +8,26 @@ description: |- # google\_pubsub\_subscripion -Creates a subscription in Google's pubsub queueing system. For more information see +Creates a subscription in Google's pubsub queueing system. For more information see [the official documentation](https://cloud.google.com/pubsub/docs) and [API](https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions). ## Example Usage -``` +```js resource "google_pubsub_subscription" "default" { - name = "default-subscription" - topic = "default-topic" - ack_deadline_seconds = 20 - push_config { - endpoint = "https://example.com/push" - attributes { - x-goog-version = "v1" - } + name = "default-subscription" + topic = "default-topic" + + ack_deadline_seconds = 20 + + push_config { + endpoint = "https://example.com/push" + attributes { + x-goog-version = "v1" } + } } ``` @@ -39,10 +41,18 @@ The following arguments are supported: * `topic` - (Required) A topic to bind this subscription to, required by pubsub. Changing this forces a new resource to be created. +- - - + * `ack_deadline_seconds` - (Optional) The maximum number of seconds a subscriber has to acknowledge a received message, otherwise the message is redelivered. Changing this forces a new resource to be created. +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `push_config` - (Optional) Block configuration for push options. More + configuration options are detailed below. + The optional `push_config` block supports: * `push_endpoint` - (Optional) The URL of the endpoint to which messages should @@ -54,3 +64,7 @@ The optional `push_config` block supports: delivery. For more information, read [the API docs here](https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions#PushConfig.FIELDS.attributes). Changing this forces a new resource to be created. + +## Attributes Reference + +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/pubsub_topic.html.markdown b/website/source/docs/providers/google/r/pubsub_topic.html.markdown index e371ddef196a..9d8473bf8c96 100644 --- a/website/source/docs/providers/google/r/pubsub_topic.html.markdown +++ b/website/source/docs/providers/google/r/pubsub_topic.html.markdown @@ -8,16 +8,16 @@ description: |- # google\_pubsub\_topic -Creates a topic in Google's pubsub queueing system. For more information see +Creates a topic in Google's pubsub queueing system. For more information see [the official documentation](https://cloud.google.com/pubsub/docs) and [API](https://cloud.google.com/pubsub/reference/rest/v1/projects.topics). ## Example Usage -``` +```js resource "google_pubsub_topic" "default" { - name = "default-topic" + name = "default-topic" } ``` @@ -28,8 +28,11 @@ The following arguments are supported: * `name` - (Required) A unique name for the resource, required by pubsub. Changing this forces a new resource to be created. -## Attributes Reference +- - - -The following attributes are exported: +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +## Attributes Reference -* `name` - The name of the resource. +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/sql_database.html.markdown b/website/source/docs/providers/google/r/sql_database.html.markdown index 07413c39043d..8d6958c8fc5b 100644 --- a/website/source/docs/providers/google/r/sql_database.html.markdown +++ b/website/source/docs/providers/google/r/sql_database.html.markdown @@ -14,20 +14,19 @@ Creates a new Google SQL Database on a Google SQL Database Instance. For more in Example creating a SQL Database. -``` +```js resource "google_sql_database_instance" "master" { - name = "master-instance" + name = "master-instance" - settings { - tier = "D0" - } + settings { + tier = "D0" + } } resource "google_sql_database" "users" { - name = "image-store-bucket" - instance = "${google_sql_database_instance.master.name}" + name = "image-store-bucket" + instance = "${google_sql_database_instance.master.name}" } - ``` ## Argument Reference @@ -38,8 +37,14 @@ The following arguments are supported: * `instance` - (Required) The name of containing instance. +- - - + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: * `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/sql_database_instance.html.markdown b/website/source/docs/providers/google/r/sql_database_instance.html.markdown index c00f8b526bbb..c6db7cc029ab 100644 --- a/website/source/docs/providers/google/r/sql_database_instance.html.markdown +++ b/website/source/docs/providers/google/r/sql_database_instance.html.markdown @@ -14,13 +14,13 @@ Creates a new Google SQL Database Instance. For more information, see the [offic Example creating a SQL Database. -``` +```js resource "google_sql_database_instance" "master" { - name = "master-instance" + name = "master-instance" - settings { - tier = "D0" - } + settings { + tier = "D0" + } } ``` @@ -28,42 +28,53 @@ resource "google_sql_database_instance" "master" { The following arguments are supported: -* `name` - (Optional, Computed) The name of the instance. If the name is left - blank, Terraform will randomly generate one when the instance is first - created. This is done because after a name is used, it cannot be reused - for up to [two months](https://cloud.google.com/sql/docs/delete-instance). - * `region` - (Required) The region the instance will sit in. Note, this does - not line up with the Google Compute Engine (GCE) regions - your options are - `us-central`, `asia-west1`, `europe-west1`, and `us-east1`. + not line up with the Google Compute Engine (GCE) regions - your options are + `us-central`, `asia-west1`, `europe-west1`, and `us-east1`. -* `master_instance_name` - (Optional) The name of the instance that will act as - the master in the replication setup. Note, this requires the master to have - `binary_log_enabled` set, as well as existing backups. +* `settings` - (Required) The settings to use for the database. The + configuration is detailed below. + +- - - * `database_version` - (Optional, Default: `MYSQL_5_5`) The MySQL version to - use. Can be either `MYSQL_5_5` or `MYSQL_5_6`. + use. Can be either `MYSQL_5_5` or `MYSQL_5_6`. + +* `name` - (Optional, Computed) The name of the instance. If the name is left + blank, Terraform will randomly generate one when the instance is first + created. This is done because after a name is used, it cannot be reused for + up to [two months](https://cloud.google.com/sql/docs/delete-instance). + +* `master_instance_name` - (Optional) The name of the instance that will act as + the master in the replication setup. Note, this requires the master to have + `binary_log_enabled` set, as well as existing backups. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `replica_configuration` - (Optional) The configuration for replication. The + configuration is detailed below. The required `settings` block supports: * `tier` - (Required) The machine tier to use. See - [pricing](https://cloud.google.com/sql/pricing) for more details and - supported versions. + [pricing](https://cloud.google.com/sql/pricing) for more details and + supported versions. * `activation_policy` - (Optional) This specifies when the instance should be - active. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`. + active. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`. -* `authorized_gae_applications` - (Optional) A list of Google App Engine (GAE) project names that - are allowed to access this instance. +* `authorized_gae_applications` - (Optional) A list of Google App Engine (GAE) + project names that are allowed to access this instance. * `crash_safe_replication` - (Optional) Specific to read instances, indicates - when crash-safe replication flags are enabled. + when crash-safe replication flags are enabled. * `pricing_plan` - (Optional) Pricing plan for this instance, can be one of - `PER_USE` or `PACKAGE`. + `PER_USE` or `PACKAGE`. -* `replication_type` - (Optional) Replication type for this instance, can be one of - `ASYNCHRONOUS` or `SYNCHRONOUS`. +* `replication_type` - (Optional) Replication type for this instance, can be one + of `ASYNCHRONOUS` or `SYNCHRONOUS`. The optional `settings.database_flags` sublist supports: @@ -74,61 +85,60 @@ The optional `settings.database_flags` sublist supports: The optional `settings.backup_configuration` subblock supports: * `binary_log_enabled` - (Optional) True iff binary logging is enabled. If - `logging` is false, this must be as well. + `logging` is false, this must be as well. * `enabled` - (Optional) True iff backup configuration is enabled. * `start_time` - (Optional) `HH:MM` format time indicating when backup - configuration starts. + configuration starts. The optional `settings.ip_configuration` subblock supports: * `ipv4_enabled` - (Optional) True iff the instance should be assigned an IP - address. + address. * `require_ssl` - (Optional) True iff mysqld should default to `REQUIRE X509` - for users connecting over IP. + for users connecting over IP. The optional `settings.ip_configuration.authorized_networks[]` sublist supports: -* `expiration_time` - (Optional) The [RFC - 3339](https://tools.ietf.org/html/rfc3339) formatted date time string - indicating when this whitelist expires. +* `expiration_time` - (Optional) The [RFC 3339](https://tools.ietf.org/html/rfc3339) + formatted date time string indicating when this whitelist expires. * `name` - (Optional) A name for this whitelist entry. * `value` - (Optional) A CIDR notation IPv4 or IPv6 address that is allowed to - access this instance. Must be set even if other two attributes are not for - the whitelist to become active. + access this instance. Must be set even if other two attributes are not for + the whitelist to become active. The optional `settings.location_preference` subblock supports: * `follow_gae_application` - (Optional) A GAE application whose zone to remain - in. Must be in the same region as this instance. + in. Must be in the same region as this instance. * `zone` - (Optional) The preferred compute engine - [zone](https://cloud.google.com/compute/docs/zones?hl=en). + [zone](https://cloud.google.com/compute/docs/zones?hl=en). -The optional `replica_configuration` block must have -`master_instance_name` set to work, cannot be updated, and supports: +The optional `replica_configuration` block must have `master_instance_name` set +to work, cannot be updated, and supports: * `ca_certificate` - (Optional) PEM representation of the trusted CA's x509 - certificate. + certificate. * `client_certificate` - (Optional) PEM representation of the slave's x509 - certificate. + certificate. -* `client_key` - (Optional) PEM representation of the slave's private key. - The corresponding public key in encoded in the `client_certificate`. +* `client_key` - (Optional) PEM representation of the slave's private key. The + corresponding public key in encoded in the `client_certificate`. * `connect_retry_interval` - (Optional, Default: 60) The number of seconds - between connect retries. + between connect retries. * `dump_file_path` - (Optional) Path to a SQL file in GCS from which slave - instances are created. Format is `gs://bucket/filename`. + instances are created. Format is `gs://bucket/filename`. * `master_heartbeat_period` - (Optional) Time in ms between replication - heartbeats. + heartbeats. * `password` - (Optional) Password for the replication connection. @@ -137,22 +147,19 @@ The optional `replica_configuration` block must have * `username` - (Optional) Username for replication connection. * `verify_server_certificate` - (Optional) True iff the master's common name - value is checked during the SSL handshake. + value is checked during the SSL handshake. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: -* `self_link` - The URI of the created resource. +* `ip_address.ip_address` - The IPv4 address assigned. -The `settings` block exports: +* `ip_address.time_to_retire` - The time this IP address will be retired, in RFC + 3339 format. -* `version` - Used to make sure changes to the `settings` block are atomic. - -The `ip_address` block exports a list of IPv4 addresses assigned to this -instance, with the following properties: - -* `ip_address` - The IPv4 address assigned. +* `self_link` - The URI of the created resource. -* `time_to_retire` - The time this IP address will be retired, in RFC 3339 - format. +* `settings.version` - Used to make sure changes to the `settings` block are + atomic. diff --git a/website/source/docs/providers/google/r/sql_user.html.markdown b/website/source/docs/providers/google/r/sql_user.html.markdown index e7275b0ae55c..a7fb645971e9 100644 --- a/website/source/docs/providers/google/r/sql_user.html.markdown +++ b/website/source/docs/providers/google/r/sql_user.html.markdown @@ -14,34 +14,42 @@ Creates a new Google SQL User on a Google SQL User Instance. For more informatio Example creating a SQL User. -``` +```js resource "google_sql_database_instance" "master" { - name = "master-instance" + name = "master-instance" - settings { - tier = "D0" - } + settings { + tier = "D0" + } } resource "google_sql_user" "users" { - name = "me" - instance = "${google_sql_database_instance.master.name}" - host = "me.com" + name = "me" + instance = "${google_sql_database_instance.master.name}" + host = "me.com" } - ``` ## Argument Reference The following arguments are supported: -* `name` - (Required) The name of the user. - Changing this forces a new resource to be created. - * `host` - (Required) The host the user can connect from. Can be an IP address. - Changing this forces a new resource to be created. + Changing this forces a new resource to be created. + +* `instance` - (Required) The name of the Cloud SQL instance. Changing this + forces a new resource to be created. + +* `name` - (Required) The name of the user. Changing this forces a new resource + to be created. * `password` - (Required) The users password. Can be updated. -* `instance` - (Required) The name of the Cloud SQL instance. - Changing this forces a new resource to be created. +- - - + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +## Attributes Reference + +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/storage_bucket.html.markdown b/website/source/docs/providers/google/r/storage_bucket.html.markdown index a527fa2df670..b32b301d6d89 100644 --- a/website/source/docs/providers/google/r/storage_bucket.html.markdown +++ b/website/source/docs/providers/google/r/storage_bucket.html.markdown @@ -15,16 +15,16 @@ Creates a new bucket in Google cloud storage service(GCS). Currently, it will no Example creating a private bucket in standard storage, in the EU region. -``` +```js resource "google_storage_bucket" "image-store" { - name = "image-store-bucket" - location = "EU" - website { - main_page_suffix = "index.html" - not_found_page = "404.html" - } -} + name = "image-store-bucket" + location = "EU" + website { + main_page_suffix = "index.html" + not_found_page = "404.html" + } +} ``` ## Argument Reference @@ -32,18 +32,35 @@ resource "google_storage_bucket" "image-store" { The following arguments are supported: * `name` - (Required) The name of the bucket. + +- - - + +* `force_destroy` - (Optional, Default: false) When deleting a bucket, this + boolean option will delete all contained objects. If you try to delete a + bucket that contains objects, Terraform will fail that run. + +* `location` - (Optional, Default: 'US') The [GCS location](https://cloud.google.com/storage/docs/bucket-locations) + + * `predefined_acl` - (Optional, Deprecated) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) to apply. Please switch to `google_storage_bucket_acl.predefined_acl`. -* `location` - (Optional, Default: 'US') The [GCS location](https://cloud.google.com/storage/docs/bucket-locations) -* `force_destroy` - (Optional, Default: false) When deleting a bucket, this boolean option will delete all contained objects. If you try to delete a bucket that contains objects, Terraform will fail that run. + +* `project` - (Optional) The project in which the resource belongs. If it + is not provided, the provider project is used. + +* `website` - (Optional) Configuration if the bucket acts as a website. The optional `website` block supports: -* `main_page_suffix` - (Optional) Behaves as the bucket's directory index where missing objects are treated as potential directories. -* `not_found_page` - (Optional) The custom object to return when a requested resource is not found. +* `main_page_suffix` - (Optional) Behaves as the bucket's directory index where + missing objects are treated as potential directories. + +* `not_found_page` - (Optional) The custom object to return when a requested + resource is not found. ## Attributes Reference -The following attributes are exported: +In addition to the arguments listed above, the following computed attributes are +exported: * `self_link` - The URI of the created resource. diff --git a/website/source/docs/providers/google/r/storage_bucket_acl.html.markdown b/website/source/docs/providers/google/r/storage_bucket_acl.html.markdown index c9cbf5339bb6..17967ead324f 100644 --- a/website/source/docs/providers/google/r/storage_bucket_acl.html.markdown +++ b/website/source/docs/providers/google/r/storage_bucket_acl.html.markdown @@ -14,23 +14,34 @@ Creates a new bucket ACL in Google cloud storage service(GCS). Example creating an ACL on a bucket with one owner, and one reader. -``` +```js resource "google_storage_bucket" "image-store" { - name = "image-store-bucket" - location = "EU" + name = "image-store-bucket" + location = "EU" } resource "google_storage_bucket_acl" "image-store-acl" { - bucket = "${google_storage_bucket.image_store.name}" - role_entity = ["OWNER:user-my.email@gmail.com", - "READER:group-mygroup"] -} + bucket = "${google_storage_bucket.image_store.name}" + role_entity = [ + "OWNER:user-my.email@gmail.com", + "READER:group-mygroup", + ] +} ``` ## Argument Reference * `bucket` - (Required) The name of the bucket it applies to. -* `predefined_acl` - (Optional) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) to apply. Must be set if both `role_entity` and `default_acl` are not. + +- - - + * `default_acl` - (Optional) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) to apply to future buckets. Must be set both `role_entity` and `predefined_acl` are not. + +* `predefined_acl` - (Optional) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) to apply. Must be set if both `role_entity` and `default_acl` are not. + * `role_entity` - (Optional) List of role/entity pairs in the form `ROLE:entity`. See [GCS Bucket ACL documentation](https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls) for more details. Must be set if both `predefined_acl` and `default_acl` are not. + +## Attributes Reference + +Only the arguments listed above are exposed as attributes. diff --git a/website/source/docs/providers/google/r/storage_bucket_object.html.markdown b/website/source/docs/providers/google/r/storage_bucket_object.html.markdown index ecbefd1be699..20092b0ee3e6 100644 --- a/website/source/docs/providers/google/r/storage_bucket_object.html.markdown +++ b/website/source/docs/providers/google/r/storage_bucket_object.html.markdown @@ -15,36 +15,39 @@ Creates a new object inside an exisiting bucket in Google cloud storage service Example creating a public object in an existing `image-store` bucket. -``` +```js resource "google_storage_bucket_object" "picture" { - name = "butterfly01" - source = "/images/nature/garden-tiger-moth.jpg" - bucket = "image-store" + name = "butterfly01" + source = "/images/nature/garden-tiger-moth.jpg" + bucket = "image-store" } - ``` ## Argument Reference The following arguments are supported: -* `name` - (Required) The name of the object. - * `bucket` - (Required) The name of the containing bucket. -* `source` - (Optional) A path to the data you want to upload. Must be defined -if `content` is not. +* `name` - (Required) The name of the object. + +- - - * `content` - (Optional) Data as `string` to be uploaded. Must be defined if -`source` is not. + `source` is not. * `predefined_acl` - (Optional, Deprecated) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) apply. Please switch to `google_storage_object_acl.predefined_acl`. -## Attributes Reference -The following attributes are exported: +* `source` - (Optional) A path to the data you want to upload. Must be defined + if `content` is not. -* `md5hash` - (Computed) Base 64 MD5 hash of the uploaded data. +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are +exported: * `crc32c` - (Computed) Base 64 CRC32 hash of the uploaded data. + +* `md5hash` - (Computed) Base 64 MD5 hash of the uploaded data. diff --git a/website/source/docs/providers/google/r/storage_object_acl.html.markdown b/website/source/docs/providers/google/r/storage_object_acl.html.markdown index 9f27f8e3862a..046e310c1d33 100644 --- a/website/source/docs/providers/google/r/storage_object_acl.html.markdown +++ b/website/source/docs/providers/google/r/storage_object_acl.html.markdown @@ -14,30 +14,41 @@ Creates a new object ACL in Google cloud storage service (GCS) Create an object ACL with one owner and one reader. -``` +```js resource "google_storage_bucket" "image-store" { - name = "image-store-bucket" - location = "EU" + name = "image-store-bucket" + location = "EU" } resource "google_storage_bucket_object" "image" { - name = "image1" - bucket = "${google_storage_bucket.name}" - source = "image1.jpg" + name = "image1" + bucket = "${google_storage_bucket.name}" + source = "image1.jpg" } resource "google_storage_object_acl" "image-store-acl" { - bucket = "${google_storage_bucket.image_store.name}" - object = "${google_storage_bucket_object.image_store.name}" - role_entity = ["OWNER:user-my.email@gmail.com", - "READER:group-mygroup"] -} + bucket = "${google_storage_bucket.image_store.name}" + object = "${google_storage_bucket_object.image_store.name}" + role_entity = [ + "OWNER:user-my.email@gmail.com", + "READER:group-mygroup", + ] +} ``` ## Argument Reference * `bucket` - (Required) The name of the bucket it applies to. + * `object` - (Required) The name of the object it applies to. + +- - - + * `predefined_acl` - (Optional) The [canned GCS ACL](https://cloud.google.com/storage/docs/access-control#predefined-acl) to apply. Must be set if `role_entity` is not. + * `role_entity` - (Optional) List of role/entity pairs in the form `ROLE:entity`. See [GCS Object ACL documentation](https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls) for more details. Must be set if `predefined_acl` is not. + +## Attributes Reference + +Only the arguments listed above are exposed as attributes. From ca57cb1a90d004128b461ac77e537ef2268bf2cf Mon Sep 17 00:00:00 2001 From: James Nugent Date: Sun, 10 Apr 2016 17:16:10 -0500 Subject: [PATCH 047/665] deps: Update github.com/fsouza/go-dockerclient This introduces the fix in fsouza/go-dockerclient#497, which in turn fixes fsouza/go-dockerclient#296. This allows Terraform to build fully on OpenBSD. --- Godeps/Godeps.json | 36 +-- .../fsouza/go-dockerclient/.travis.yml | 19 +- .../github.com/fsouza/go-dockerclient/AUTHORS | 7 + .../github.com/fsouza/go-dockerclient/LICENSE | 2 +- .../fsouza/go-dockerclient/Makefile | 29 ++- .../fsouza/go-dockerclient/README.markdown | 2 +- .../github.com/fsouza/go-dockerclient/auth.go | 8 +- .../fsouza/go-dockerclient/client.go | 4 +- .../fsouza/go-dockerclient/container.go | 216 +++++++++++++----- .../fsouza/go-dockerclient/event.go | 76 +++++- .../docker/docker/pkg/system/chtimes_unix.go | 14 ++ .../docker/pkg/system/chtimes_windows.go | 27 +++ .../docker/docker/pkg/system/stat_openbsd.go | 15 ++ .../docker/pkg/system/stat_unsupported.go | 2 +- .../golang.org/x/net/context/context.go | 12 +- .../fsouza/go-dockerclient/image.go | 24 ++ .../github.com/fsouza/go-dockerclient/misc.go | 75 +++++- .../fsouza/go-dockerclient/network.go | 65 +++++- 18 files changed, 511 insertions(+), 122 deletions(-) create mode 100644 vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go create mode 100644 vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go create mode 100644 vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1d1a089d92ce..45a22d950f1e 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -561,75 +561,75 @@ }, { "ImportPath": "github.com/fsouza/go-dockerclient", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/homedir", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/pools", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/promise", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/stdcopy", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/net/context", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix", - "Rev": "02a8beb401b20e112cff3ea740545960b667eab1" + "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { "ImportPath": "github.com/go-chef/chef", diff --git a/vendor/github.com/fsouza/go-dockerclient/.travis.yml b/vendor/github.com/fsouza/go-dockerclient/.travis.yml index aee4e902a4b8..68b137ad282c 100644 --- a/vendor/github.com/fsouza/go-dockerclient/.travis.yml +++ b/vendor/github.com/fsouza/go-dockerclient/.travis.yml @@ -1,22 +1,27 @@ language: go sudo: required go: - - 1.3.3 - 1.4.2 - 1.5.3 - - 1.6rc1 + - 1.6 - tip +os: + - linux + - osx env: - - GOARCH=amd64 DOCKER_VERSION=1.7.1 - - GOARCH=386 DOCKER_VERSION=1.7.1 - GOARCH=amd64 DOCKER_VERSION=1.8.3 - GOARCH=386 DOCKER_VERSION=1.8.3 - GOARCH=amd64 DOCKER_VERSION=1.9.1 - GOARCH=386 DOCKER_VERSION=1.9.1 + - GOARCH=amd64 DOCKER_VERSION=1.10.3 + - GOARCH=386 DOCKER_VERSION=1.10.3 install: - - make prepare_docker + - travis_retry travis-scripts/install.bash script: - - make test - - DOCKER_HOST=tcp://127.0.0.1:2375 make integration + - travis-scripts/run-tests.bash services: - docker +matrix: + fast_finish: true + allow_failures: + - go: tip diff --git a/vendor/github.com/fsouza/go-dockerclient/AUTHORS b/vendor/github.com/fsouza/go-dockerclient/AUTHORS index 0c42ae3444a9..bb71cc345b12 100644 --- a/vendor/github.com/fsouza/go-dockerclient/AUTHORS +++ b/vendor/github.com/fsouza/go-dockerclient/AUTHORS @@ -14,6 +14,7 @@ Ben Marini Ben McCann Ben Parees Benno van den Berg +Bradley Cicenas Brendan Fosberry Brian Lalor Brian P. Hamachek @@ -48,6 +49,8 @@ Fabio Rehm Fatih Arslan Flavia Missi Francisco Souza +Frank Groeneveld +George Moura Grégoire Delattre Guillermo Álvarez Fernández Harry Zhang @@ -84,7 +87,9 @@ Michael Schmatz Michal Fojtik Mike Dillon Mrunal Patel +Nate Jones Nguyen Sy Thanh Son +Nicholas Van Wiggeren Nick Ethier Omeid Matten Orivej Desh @@ -98,9 +103,11 @@ Philippe Lafoucrière Rafe Colton Rob Miller Robert Williamson +Roman Khlystik Salvador Gironès Sam Rijs Sami Wagiaalla +Samuel Archambault Samuel Karp Silas Sewell Simon Eskildsen diff --git a/vendor/github.com/fsouza/go-dockerclient/LICENSE b/vendor/github.com/fsouza/go-dockerclient/LICENSE index 4e11de1007ae..b1cdd4cd20cc 100644 --- a/vendor/github.com/fsouza/go-dockerclient/LICENSE +++ b/vendor/github.com/fsouza/go-dockerclient/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015, go-dockerclient authors +Copyright (c) 2016, go-dockerclient authors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/vendor/github.com/fsouza/go-dockerclient/Makefile b/vendor/github.com/fsouza/go-dockerclient/Makefile index 205d8f3c22db..dd8c73b1b793 100644 --- a/vendor/github.com/fsouza/go-dockerclient/Makefile +++ b/vendor/github.com/fsouza/go-dockerclient/Makefile @@ -11,8 +11,7 @@ cov \ clean -SRCS = $(shell git ls-files '*.go' | grep -v '^external/') -PKGS = ./. ./testing +PKGS = . ./testing all: test @@ -22,32 +21,30 @@ vendor: lint: @ go get -v github.com/golang/lint/golint - $(foreach file,$(SRCS),golint $(file) || exit;) + @for file in $$(git ls-files '*.go' | grep -v 'external/'); do \ + export output="$$(golint $${file} | grep -v 'type name will be used as docker.DockerInfo')"; \ + [ -n "$${output}" ] && echo "$${output}" && export status=1; \ + done; \ + exit $${status:-0} vet: - @-go get -v golang.org/x/tools/cmd/vet $(foreach pkg,$(PKGS),go vet $(pkg);) fmt: - gofmt -w $(SRCS) + gofmt -s -w $(PKGS) fmtcheck: - $(foreach file,$(SRCS),gofmt -d $(file);) - -prepare_docker: - sudo stop docker - sudo rm -rf /var/lib/docker - sudo rm -f `which docker` - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D - echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list - sudo apt-get update - sudo apt-get install docker-engine=$(DOCKER_VERSION)-0~$(shell lsb_release -cs) -y --force-yes + @ export output=$$(gofmt -s -d $(PKGS)); \ + [ -n "$${output}" ] && echo "$${output}" && export status=1; \ + exit $${status:-0} pretest: lint vet fmtcheck -test: pretest +gotest: $(foreach pkg,$(PKGS),go test $(pkg) || exit;) +test: pretest gotest + integration: go test -tags docker_integration -run TestIntegration -v diff --git a/vendor/github.com/fsouza/go-dockerclient/README.markdown b/vendor/github.com/fsouza/go-dockerclient/README.markdown index b75a7e920b64..b915039f19b9 100644 --- a/vendor/github.com/fsouza/go-dockerclient/README.markdown +++ b/vendor/github.com/fsouza/go-dockerclient/README.markdown @@ -4,7 +4,7 @@ [![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient) This package presents a client for the Docker remote API. It also provides -support for the extensions in the [Swarm API](https://docs.docker.com/swarm/api/swarm-api/). +support for the extensions in the [Swarm API](https://docs.docker.com/swarm/swarm-api/). This package also provides support for docker's network API, which is a simple passthrough to the libnetwork remote API. Note that docker's network API is diff --git a/vendor/github.com/fsouza/go-dockerclient/auth.go b/vendor/github.com/fsouza/go-dockerclient/auth.go index 775c70c0b225..1be277c96fce 100644 --- a/vendor/github.com/fsouza/go-dockerclient/auth.go +++ b/vendor/github.com/fsouza/go-dockerclient/auth.go @@ -82,10 +82,12 @@ func parseDockerConfig(r io.Reader) (map[string]dockerConfig, error) { buf.ReadFrom(r) byteData := buf.Bytes() - var confsWrapper map[string]map[string]dockerConfig + confsWrapper := struct { + Auths map[string]dockerConfig `json:"auths"` + }{} if err := json.Unmarshal(byteData, &confsWrapper); err == nil { - if confs, ok := confsWrapper["auths"]; ok { - return confs, nil + if len(confsWrapper.Auths) > 0 { + return confsWrapper.Auths, nil } } diff --git a/vendor/github.com/fsouza/go-dockerclient/client.go b/vendor/github.com/fsouza/go-dockerclient/client.go index cf9d616789d3..d893ba684ab9 100644 --- a/vendor/github.com/fsouza/go-dockerclient/client.go +++ b/vendor/github.com/fsouza/go-dockerclient/client.go @@ -555,6 +555,8 @@ type hijackOptions struct { data interface{} } +// CloseWaiter is an interface with methods for closing the underlying resource +// and then waiting for it to finish processing. type CloseWaiter interface { io.Closer Wait() error @@ -587,7 +589,7 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close if err != nil { return nil, err } - req.Header.Set("Content-Type", "plain/text") + req.Header.Set("Content-Type", "application/json") req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", "tcp") protocol := c.endpointURL.Scheme diff --git a/vendor/github.com/fsouza/go-dockerclient/container.go b/vendor/github.com/fsouza/go-dockerclient/container.go index 317814b90bfb..fcf11535165b 100644 --- a/vendor/github.com/fsouza/go-dockerclient/container.go +++ b/vendor/github.com/fsouza/go-dockerclient/container.go @@ -14,6 +14,8 @@ import ( "strconv" "strings" "time" + + "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units" ) // ErrContainerAlreadyExists is the error returned by CreateContainer when the @@ -52,7 +54,14 @@ type APIContainers struct { SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty"` SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,omitempty"` Names []string `json:"Names,omitempty" yaml:"Names,omitempty"` - Labels map[string]string `json:"Labels,omitempty" yaml:"Labels, omitempty"` + Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"` + Networks NetworkList `json:"NetworkSettings,omitempty" yaml:"NetworkSettings,omitempty"` +} + +// NetworkList encapsulates a map of networks, as returned by the Docker API in +// ListContainers. +type NetworkList struct { + Networks map[string]ContainerNetwork `json:"Networks" yaml:"Networks,omitempty"` } // ListContainers returns a slice of containers matching the given criteria. @@ -92,26 +101,73 @@ func (p Port) Proto() string { // State represents the state of a container. type State struct { - Running bool `json:"Running,omitempty" yaml:"Running,omitempty"` - Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"` - Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"` - OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"` - Pid int `json:"Pid,omitempty" yaml:"Pid,omitempty"` - ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"` - Error string `json:"Error,omitempty" yaml:"Error,omitempty"` - StartedAt time.Time `json:"StartedAt,omitempty" yaml:"StartedAt,omitempty"` - FinishedAt time.Time `json:"FinishedAt,omitempty" yaml:"FinishedAt,omitempty"` -} - -// String returns the string representation of a state. + Status string `json:"Status,omitempty" yaml:"Status,omitempty"` + Running bool `json:"Running,omitempty" yaml:"Running,omitempty"` + Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"` + Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"` + OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"` + RemovalInProgress bool `json:"RemovalInProgress,omitempty" yaml:"RemovalInProgress,omitempty"` + Dead bool `json:"Dead,omitempty" yaml:"Dead,omitempty"` + Pid int `json:"Pid,omitempty" yaml:"Pid,omitempty"` + ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"` + Error string `json:"Error,omitempty" yaml:"Error,omitempty"` + StartedAt time.Time `json:"StartedAt,omitempty" yaml:"StartedAt,omitempty"` + FinishedAt time.Time `json:"FinishedAt,omitempty" yaml:"FinishedAt,omitempty"` +} + +// String returns a human-readable description of the state func (s *State) String() string { + if s.Running { + if s.Paused { + return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) + } + if s.Restarting { + return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) + } + + return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) + } + + if s.RemovalInProgress { + return "Removal In Progress" + } + + if s.Dead { + return "Dead" + } + + if s.StartedAt.IsZero() { + return "Created" + } + + if s.FinishedAt.IsZero() { + return "" + } + + return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) +} + +// StateString returns a single string to describe state +func (s *State) StateString() string { if s.Running { if s.Paused { return "paused" } - return fmt.Sprintf("Up %s", time.Now().UTC().Sub(s.StartedAt)) + if s.Restarting { + return "restarting" + } + return "running" + } + + if s.Dead { + return "dead" } - return fmt.Sprintf("Exit %d", s.ExitCode) + + if s.StartedAt.IsZero() { + return "created" + } + + return "exited" } // PortBinding represents the host/container port mapping as returned in the @@ -135,6 +191,7 @@ type ContainerNetwork struct { IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"` Gateway string `json:"Gateway,omitempty" yaml:"Gateway,omitempty"` EndpointID string `json:"EndpointID,omitempty" yaml:"EndpointID,omitempty"` + NetworkID string `json:"NetworkID,omitempty" yaml:"NetworkID,omitempty"` } // NetworkSettings contains network-related information about a container @@ -308,6 +365,34 @@ type Container struct { AppArmorProfile string `json:"AppArmorProfile,omitempty" yaml:"AppArmorProfile,omitempty"` } +// UpdateContainerOptions specify parameters to the UpdateContainer function. +// +// See https://goo.gl/Y6fXUy for more details. +type UpdateContainerOptions struct { + BlkioWeight int `json:"BlkioWeight"` + CPUShares int `json:"CpuShares"` + CPUPeriod int `json:"CpuPeriod"` + CPUQuota int `json:"CpuQuota"` + CpusetCpus string `json:"CpusetCpus"` + CpusetMems string `json:"CpusetMems"` + Memory int `json:"Memory"` + MemorySwap int `json:"MemorySwap"` + MemoryReservation int `json:"MemoryReservation"` + KernelMemory int `json:"KernelMemory"` +} + +// UpdateContainer updates the container at ID with the options +// +// See https://goo.gl/Y6fXUy for more details. +func (c *Client) UpdateContainer(id string, opts UpdateContainerOptions) error { + resp, err := c.do("POST", fmt.Sprintf("/containers/"+id+"/update"), doOptions{data: opts, forceJSON: true}) + if err != nil { + return err + } + defer resp.Body.Close() + return nil +} + // RenameContainerOptions specify parameters to the RenameContainer function. // // See https://goo.gl/laSOIy for more details. @@ -469,48 +554,71 @@ type Device struct { CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty"` } +// BlockWeight represents a relative device weight for an individual device inside +// of a container +// +// See https://goo.gl/FSdP0H for more details. +type BlockWeight struct { + Path string `json:"Path,omitempty"` + Weight string `json:"Weight,omitempty"` +} + +// BlockLimit represents a read/write limit in IOPS or Bandwidth for a device +// inside of a container +// +// See https://goo.gl/FSdP0H for more details. +type BlockLimit struct { + Path string `json:"Path,omitempty"` + Rate string `json:"Rate,omitempty"` +} + // HostConfig contains the container options related to starting a container on // a given host type HostConfig struct { - Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"` - CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"` - CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"` - GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"` - ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"` - LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"` - Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"` - PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"` - Links []string `json:"Links,omitempty" yaml:"Links,omitempty"` - PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty"` - DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.10 and above only - DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"` - DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"` - ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"` - VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"` - NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"` - IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"` - PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"` - UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"` - RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"` - Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"` - LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"` - ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"` - SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"` - CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"` - Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` - MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"` - MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"` - OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"` - CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"` - CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"` - CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"` - CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"` - CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"` - CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"` - BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"` - Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"` - VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"` - OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"` + Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"` + CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"` + CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"` + GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"` + ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"` + LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"` + Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"` + PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"` + Links []string `json:"Links,omitempty" yaml:"Links,omitempty"` + PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty"` + DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.10 and above only + DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"` + DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"` + ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"` + VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"` + NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"` + IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"` + PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"` + UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"` + RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"` + Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"` + LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"` + ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"` + SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"` + CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"` + Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` + MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"` + MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"` + OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"` + CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"` + CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"` + CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"` + CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"` + CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"` + CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"` + BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"` + BlkioWeightDevice []BlockWeight `json:"BlkioWeightDevice,omitempty" yaml:"BlkioWeightDevice"` + BlkioDeviceReadBps []BlockLimit `json:"BlkioDeviceReadBps,omitempty" yaml:"BlkioDeviceReadBps"` + BlkioDeviceReadIOps []BlockLimit `json:"BlkioDeviceReadIOps,omitempty" yaml:"BlkioDeviceReadIOps"` + BlkioDeviceWriteBps []BlockLimit `json:"BlkioDeviceWriteBps,omitempty" yaml:"BlkioDeviceWriteBps"` + BlkioDeviceWriteIOps []BlockLimit `json:"BlkioDeviceWriteIOps,omitempty" yaml:"BlkioDeviceWriteIOps"` + Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"` + VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"` + OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"` } // StartContainer starts a container, returning an error in case of failure. diff --git a/vendor/github.com/fsouza/go-dockerclient/event.go b/vendor/github.com/fsouza/go-dockerclient/event.go index eaffddb825fc..83b5cf52d57a 100644 --- a/vendor/github.com/fsouza/go-dockerclient/event.go +++ b/vendor/github.com/fsouza/go-dockerclient/event.go @@ -18,12 +18,38 @@ import ( "time" ) -// APIEvents represents an event returned by the API. +// APIEvents represents events coming from the Docker API +// The fields in the Docker API changed in API version 1.22, and +// events for more than images and containers are now fired off. +// To maintain forward and backward compatibility, go-dockerclient +// replicates the event in both the new and old format as faithfully as possible. +// +// For events that only exist in 1.22 in later, `Status` is filled in as +// `"Type:Action"` instead of just `Action` to allow for older clients to +// differentiate and not break if they rely on the pre-1.22 Status types. +// +// The transformEvent method can be consulted for more information about how +// events are translated from new/old API formats type APIEvents struct { - Status string `json:"Status,omitempty" yaml:"Status,omitempty"` - ID string `json:"ID,omitempty" yaml:"ID,omitempty"` - From string `json:"From,omitempty" yaml:"From,omitempty"` - Time int64 `json:"Time,omitempty" yaml:"Time,omitempty"` + // New API Fields in 1.22 + Action string `json:"action,omitempty"` + Type string `json:"type,omitempty"` + Actor APIActor `json:"actor,omitempty"` + + // Old API fields for < 1.22 + Status string `json:"status,omitempty"` + ID string `json:"id,omitempty"` + From string `json:"from,omitempty"` + + // Fields in both + Time int64 `json:"time,omitempty"` + TimeNano int64 `json:"timeNano,omitempty"` +} + +// APIActor represents an actor that accomplishes something for an event +type APIActor struct { + ID string `json:"id,omitempty"` + Attributes map[string]string `json:"attributes,omitempty"` } type eventMonitoringState struct { @@ -52,6 +78,7 @@ var ( // EOFEvent is sent when the event listener receives an EOF error. EOFEvent = &APIEvents{ + Type: "EOF", Status: "EOF", } ) @@ -297,8 +324,47 @@ func (c *Client) eventHijack(startTime int64, eventChan chan *APIEvents, errChan if !c.eventMonitor.isEnabled() { return } + transformEvent(&event) eventChan <- &event } }(res, conn) return nil } + +// transformEvent takes an event and determines what version it is from +// then populates both versions of the event +func transformEvent(event *APIEvents) { + // if event version is <= 1.21 there will be no Action and no Type + if event.Action == "" && event.Type == "" { + event.Action = event.Status + event.Actor.ID = event.ID + event.Actor.Attributes = map[string]string{} + switch event.Status { + case "delete", "import", "pull", "push", "tag", "untag": + event.Type = "image" + default: + event.Type = "container" + if event.From != "" { + event.Actor.Attributes["image"] = event.From + } + } + } else { + if event.Status == "" { + if event.Type == "image" || event.Type == "container" { + event.Status = event.Action + } else { + // Because just the Status has been overloaded with different Types + // if an event is not for an image or a container, we prepend the type + // to avoid problems for people relying on actions being only for + // images and containers + event.Status = event.Type + ":" + event.Action + } + } + if event.ID == "" { + event.ID = event.Actor.ID + } + if event.From == "" { + event.From = event.Actor.Attributes["image"] + } + } +} diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go new file mode 100644 index 000000000000..09d58bcbfdd4 --- /dev/null +++ b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go @@ -0,0 +1,14 @@ +// +build !windows + +package system + +import ( + "time" +) + +//setCTime will set the create time on a file. On Unix, the create +//time is updated as a side effect of setting the modified time, so +//no action is required. +func setCTime(path string, ctime time.Time) error { + return nil +} diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go new file mode 100644 index 000000000000..29458684659b --- /dev/null +++ b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go @@ -0,0 +1,27 @@ +// +build windows + +package system + +import ( + "syscall" + "time" +) + +//setCTime will set the create time on a file. On Windows, this requires +//calling SetFileTime and explicitly including the create time. +func setCTime(path string, ctime time.Time) error { + ctimespec := syscall.NsecToTimespec(ctime.UnixNano()) + pathp, e := syscall.UTF16PtrFromString(path) + if e != nil { + return e + } + h, e := syscall.CreateFile(pathp, + syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil, + syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) + if e != nil { + return e + } + defer syscall.Close(h) + c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec)) + return syscall.SetFileTime(h, &c, nil, nil) +} diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go new file mode 100644 index 000000000000..3c3b71fb2196 --- /dev/null +++ b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go @@ -0,0 +1,15 @@ +package system + +import ( + "syscall" +) + +// fromStatT creates a system.StatT type from a syscall.Stat_t type +func fromStatT(s *syscall.Stat_t) (*StatT, error) { + return &StatT{size: s.Size, + mode: uint32(s.Mode), + uid: s.Uid, + gid: s.Gid, + rdev: uint64(s.Rdev), + mtim: s.Mtim}, nil +} diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_unsupported.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_unsupported.go index c6075d4ff2ba..f53e9de4d1a1 100644 --- a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_unsupported.go +++ b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows,!freebsd,!solaris +// +build !linux,!windows,!freebsd,!solaris,!openbsd package system diff --git a/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go b/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go index 11bd8d34e6c5..46629881b97b 100644 --- a/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go +++ b/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go @@ -210,13 +210,13 @@ type CancelFunc func() // call cancel as soon as the operations running in this Context complete. func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { c := newCancelCtx(parent) - propagateCancel(parent, &c) - return &c, func() { c.cancel(true, Canceled) } + propagateCancel(parent, c) + return c, func() { c.cancel(true, Canceled) } } // newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) cancelCtx { - return cancelCtx{ +func newCancelCtx(parent Context) *cancelCtx { + return &cancelCtx{ Context: parent, done: make(chan struct{}), } @@ -259,7 +259,7 @@ func parentCancelCtx(parent Context) (*cancelCtx, bool) { case *cancelCtx: return c, true case *timerCtx: - return &c.cancelCtx, true + return c.cancelCtx, true case *valueCtx: parent = c.Context default: @@ -377,7 +377,7 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { // implement Done and Err. It implements cancel by stopping its timer then // delegating to cancelCtx.cancel. type timerCtx struct { - cancelCtx + *cancelCtx timer *time.Timer // Under cancelCtx.mu. deadline time.Time diff --git a/vendor/github.com/fsouza/go-dockerclient/image.go b/vendor/github.com/fsouza/go-dockerclient/image.go index 47da77dbeb35..ca450635407f 100644 --- a/vendor/github.com/fsouza/go-dockerclient/image.go +++ b/vendor/github.com/fsouza/go-dockerclient/image.go @@ -32,6 +32,7 @@ type APIImages struct { // Image is the type representing a docker image and its various properties type Image struct { ID string `json:"Id" yaml:"Id"` + RepoTags []string `json:"RepoTags,omitempty" yaml:"RepoTags,omitempty"` Parent string `json:"Parent,omitempty" yaml:"Parent,omitempty"` Comment string `json:"Comment,omitempty" yaml:"Comment,omitempty"` Created time.Time `json:"Created,omitempty" yaml:"Created,omitempty"` @@ -421,6 +422,17 @@ type BuildImageOptions struct { AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Registry-Config header ContextDir string `qs:"-"` Ulimits []ULimit `qs:"-"` + BuildArgs []BuildArg `qs:"-"` +} + +// BuildArg represents arguments that can be passed to the image when building +// it from a Dockerfile. +// +// For more details about the Docker building process, see +// http://goo.gl/tlPXPu. +type BuildArg struct { + Name string `json:"Name,omitempty" yaml:"Name,omitempty"` + Value string `json:"Value,omitempty" yaml:"Value,omitempty"` } // BuildImage builds an image from a tarball's url or a Dockerfile in the input @@ -463,6 +475,18 @@ func (c *Client) BuildImage(opts BuildImageOptions) error { } } + if len(opts.BuildArgs) > 0 { + v := make(map[string]string) + for _, arg := range opts.BuildArgs { + v[arg.Name] = arg.Value + } + if b, err := json.Marshal(v); err == nil { + item := url.Values(map[string][]string{}) + item.Add("buildargs", string(b)) + qs = fmt.Sprintf("%s&%s", qs, item.Encode()) + } + } + return c.stream("POST", fmt.Sprintf("/build?%s", qs), streamOptions{ setRawTerminal: true, rawJSONStream: opts.RawJSONStream, diff --git a/vendor/github.com/fsouza/go-dockerclient/misc.go b/vendor/github.com/fsouza/go-dockerclient/misc.go index 34c96531ad90..ce9e9750b086 100644 --- a/vendor/github.com/fsouza/go-dockerclient/misc.go +++ b/vendor/github.com/fsouza/go-dockerclient/misc.go @@ -4,7 +4,10 @@ package docker -import "strings" +import ( + "encoding/json" + "strings" +) // Version returns version information about the docker server. // @@ -22,17 +25,81 @@ func (c *Client) Version() (*Env, error) { return &env, nil } +// DockerInfo contains information about the Docker server +// +// See https://goo.gl/bHUoz9 for more details. +type DockerInfo struct { + ID string + Containers int + ContainersRunning int + ContainersPaused int + ContainersStopped int + Images int + Driver string + DriverStatus [][2]string + SystemStatus [][2]string + Plugins PluginsInfo + MemoryLimit bool + SwapLimit bool + KernelMemory bool + CPUCfsPeriod bool `json:"CpuCfsPeriod"` + CPUCfsQuota bool `json:"CpuCfsQuota"` + CPUShares bool + CPUSet bool + IPv4Forwarding bool + BridgeNfIptables bool + BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` + Debug bool + NFd int + OomKillDisable bool + NGoroutines int + SystemTime string + ExecutionDriver string + LoggingDriver string + CgroupDriver string + NEventsListener int + KernelVersion string + OperatingSystem string + OSType string + Architecture string + IndexServerAddress string + NCPU int + MemTotal int64 + DockerRootDir string + HTTPProxy string `json:"HttpProxy"` + HTTPSProxy string `json:"HttpsProxy"` + NoProxy string + Name string + Labels []string + ExperimentalBuild bool + ServerVersion string + ClusterStore string + ClusterAdvertise string +} + +// PluginsInfo is a struct with the plugins registered with the docker daemon +// +// for more information, see: https://goo.gl/bHUoz9 +type PluginsInfo struct { + // List of Volume plugins registered + Volume []string + // List of Network plugins registered + Network []string + // List of Authorization plugins registered + Authorization []string +} + // Info returns system-wide information about the Docker server. // // See https://goo.gl/ElTHi2 for more details. -func (c *Client) Info() (*Env, error) { +func (c *Client) Info() (*DockerInfo, error) { resp, err := c.do("GET", "/info", doOptions{}) if err != nil { return nil, err } defer resp.Body.Close() - var info Env - if err := info.Decode(resp.Body); err != nil { + var info DockerInfo + if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { return nil, err } return &info, nil diff --git a/vendor/github.com/fsouza/go-dockerclient/network.go b/vendor/github.com/fsouza/go-dockerclient/network.go index 30d54230a432..b72e91a07ca3 100644 --- a/vendor/github.com/fsouza/go-dockerclient/network.go +++ b/vendor/github.com/fsouza/go-dockerclient/network.go @@ -5,6 +5,7 @@ package docker import ( + "bytes" "encoding/json" "errors" "fmt" @@ -26,6 +27,7 @@ type Network struct { IPAM IPAMOptions Containers map[string]Endpoint Options map[string]string + Internal bool } // Endpoint contains network resources allocated and used for a container in a network @@ -55,6 +57,31 @@ func (c *Client) ListNetworks() ([]Network, error) { return networks, nil } +// NetworkFilterOpts is an aggregation of key=value that Docker +// uses to filter networks +type NetworkFilterOpts map[string]map[string]bool + +// FilteredListNetworks returns all networks with the filters applied +// +// See goo.gl/zd2mx4 for more details. +func (c *Client) FilteredListNetworks(opts NetworkFilterOpts) ([]Network, error) { + params := bytes.NewBuffer(nil) + if err := json.NewEncoder(params).Encode(&opts); err != nil { + return nil, err + } + path := "/networks?filters=" + params.String() + resp, err := c.do("GET", path, doOptions{}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var networks []Network + if err := json.NewDecoder(resp.Body).Decode(&networks); err != nil { + return nil, err + } + return networks, nil +} + // NetworkInfo returns information about a network by its ID. // // See https://goo.gl/6GugX3 for more details. @@ -158,14 +185,40 @@ func (c *Client) RemoveNetwork(id string) error { return nil } -// NetworkConnectionOptions specify parameters to the ConnectNetwork and DisconnectNetwork function. +// NetworkConnectionOptions specify parameters to the ConnectNetwork and +// DisconnectNetwork function. // -// See https://goo.gl/6GugX3 for more details. +// See https://goo.gl/RV7BJU for more details. type NetworkConnectionOptions struct { Container string + + // EndpointConfig is only applicable to the ConnectNetwork call + EndpointConfig *EndpointConfig `json:"EndpointConfig,omitempty"` + + // Force is only applicable to the DisconnectNetwork call + Force bool +} + +// EndpointConfig stores network endpoint details +// +// See https://goo.gl/RV7BJU for more details. +type EndpointConfig struct { + IPAMConfig *EndpointIPAMConfig + Links []string + Aliases []string +} + +// EndpointIPAMConfig represents IPAM configurations for an +// endpoint +// +// See https://goo.gl/RV7BJU for more details. +type EndpointIPAMConfig struct { + IPv4Address string `json:",omitempty"` + IPv6Address string `json:",omitempty"` } -// ConnectNetwork adds a container to a network or returns an error in case of failure. +// ConnectNetwork adds a container to a network or returns an error in case of +// failure. // // See https://goo.gl/6GugX3 for more details. func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error { @@ -180,7 +233,8 @@ func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error return nil } -// DisconnectNetwork removes a container from a network or returns an error in case of failure. +// DisconnectNetwork removes a container from a network or returns an error in +// case of failure. // // See https://goo.gl/6GugX3 for more details. func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error { @@ -204,7 +258,8 @@ func (err *NoSuchNetwork) Error() string { return fmt.Sprintf("No such network: %s", err.ID) } -// NoSuchNetwork is the error returned when a given network or container does not exist. +// NoSuchNetworkOrContainer is the error returned when a given network or +// container does not exist. type NoSuchNetworkOrContainer struct { NetworkID string ContainerID string From 5824036ca66f3c51a30810d78c5e23b62aafdafc Mon Sep 17 00:00:00 2001 From: Kirill Shirinkin Date: Mon, 11 Apr 2016 10:23:01 +0200 Subject: [PATCH 048/665] provider/openstack: Add value_specs for routers --- ...resource_openstack_networking_router_v2.go | 64 ++++++++++++++++++- .../r/networking_router_v2.html.markdown | 3 + 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_networking_router_v2.go b/builtin/providers/openstack/resource_openstack_networking_router_v2.go index 7b5f3b8c25a8..d4f80828cc3a 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_v2.go @@ -54,10 +54,59 @@ func resourceNetworkingRouterV2() *schema.Resource { ForceNew: true, Computed: true, }, + "value_specs": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + }, }, } } +// routerCreateOpts contains all the values needed to create a new router. There are +// no required values. +type RouterCreateOpts struct { + Name string + AdminStateUp *bool + Distributed *bool + TenantID string + GatewayInfo *routers.GatewayInfo + ValueSpecs map[string]string +} + +// ToRouterCreateMap casts a routerCreateOpts struct to a map. +func (opts RouterCreateOpts) ToRouterCreateMap() (map[string]interface{}, error) { + r := make(map[string]interface{}) + + if gophercloud.MaybeString(opts.Name) != nil { + r["name"] = opts.Name + } + + if opts.AdminStateUp != nil { + r["admin_state_up"] = opts.AdminStateUp + } + + if opts.Distributed != nil { + r["distributed"] = opts.Distributed + } + + if gophercloud.MaybeString(opts.TenantID) != nil { + r["tenant_id"] = opts.TenantID + } + + if opts.GatewayInfo != nil { + r["external_gateway_info"] = opts.GatewayInfo + } + + if opts.ValueSpecs != nil { + for k, v := range opts.ValueSpecs { + r[k] = v + } + } + + return map[string]interface{}{"router": r}, nil +} + func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) networkingClient, err := config.networkingV2Client(d.Get("region").(string)) @@ -65,9 +114,10 @@ func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error creating OpenStack networking client: %s", err) } - createOpts := routers.CreateOpts{ - Name: d.Get("name").(string), - TenantID: d.Get("tenant_id").(string), + createOpts := RouterCreateOpts{ + Name: d.Get("name").(string), + TenantID: d.Get("tenant_id").(string), + ValueSpecs: routerValueSpecs(d), } if asuRaw, ok := d.GetOk("admin_state_up"); ok { @@ -239,3 +289,11 @@ func waitForRouterDelete(networkingClient *gophercloud.ServiceClient, routerId s return r, "ACTIVE", nil } } + +func routerValueSpecs(d *schema.ResourceData) map[string]string { + m := make(map[string]string) + for key, val := range d.Get("value_specs").(map[string]interface{}) { + m[key] = val.(string) + } + return m +} diff --git a/website/source/docs/providers/openstack/r/networking_router_v2.html.markdown b/website/source/docs/providers/openstack/r/networking_router_v2.html.markdown index 04a261a38cf2..5540adb62c40 100644 --- a/website/source/docs/providers/openstack/r/networking_router_v2.html.markdown +++ b/website/source/docs/providers/openstack/r/networking_router_v2.html.markdown @@ -48,6 +48,8 @@ The following arguments are supported: * `tenant_id` - (Optional) The owner of the floating IP. Required if admin wants to create a router for another tenant. Changing this creates a new router. +* `value_specs` - (Optional) Map of additional driver-specific options. + ## Attributes Reference The following attributes are exported: @@ -57,3 +59,4 @@ The following attributes are exported: * `admin_state_up` - See Argument Reference above. * `external_gateway` - See Argument Reference above. * `tenant_id` - See Argument Reference above. +* `value_specs` - See Argument Reference above. From 7721348b0ba07ba69a893a3367e0e7fc0a1efa5a Mon Sep 17 00:00:00 2001 From: Jacob Severson Date: Mon, 11 Apr 2016 07:09:25 -0500 Subject: [PATCH 049/665] Adding privacy argument for GitHub teams for #6015 (#6116) Added the ability to set the "privacy" of a github_team resource so all teams won't automatically set to private. * Added the privacy argument to github_team * Refactored parameter validation to be general for any argument * Updated testing --- .../providers/github/resource_github_membership.go | 2 +- builtin/providers/github/resource_github_team.go | 11 +++++++++++ .../github/resource_github_team_membership.go | 2 +- .../github/resource_github_team_repository.go | 2 +- builtin/providers/github/resource_github_team_test.go | 2 ++ builtin/providers/github/util.go | 6 +++--- builtin/providers/github/util_test.go | 6 +++--- .../source/docs/providers/github/r/team.html.markdown | 3 +++ 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/builtin/providers/github/resource_github_membership.go b/builtin/providers/github/resource_github_membership.go index 2c0ec27f2f9e..8be520f98476 100644 --- a/builtin/providers/github/resource_github_membership.go +++ b/builtin/providers/github/resource_github_membership.go @@ -22,7 +22,7 @@ func resourceGithubMembership() *schema.Resource { "role": &schema.Schema{ Type: schema.TypeString, Optional: true, - ValidateFunc: validateRoleValueFunc([]string{"member", "admin"}), + ValidateFunc: validateValueFunc([]string{"member", "admin"}), Default: "member", }, }, diff --git a/builtin/providers/github/resource_github_team.go b/builtin/providers/github/resource_github_team.go index b38f8d2564df..77c4fdbe6789 100644 --- a/builtin/providers/github/resource_github_team.go +++ b/builtin/providers/github/resource_github_team.go @@ -22,6 +22,12 @@ func resourceGithubTeam() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "privacy": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "secret", + ValidateFunc: validateValueFunc([]string{"secret", "closed"}), + }, }, } } @@ -30,9 +36,11 @@ func resourceGithubTeamCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*Organization).client n := d.Get("name").(string) desc := d.Get("description").(string) + p := d.Get("privacy").(string) githubTeam, _, err := client.Organizations.CreateTeam(meta.(*Organization).name, &github.Team{ Name: &n, Description: &desc, + Privacy: &p, }) if err != nil { return err @@ -51,6 +59,7 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { } d.Set("description", team.Description) d.Set("name", team.Name) + d.Set("privacy", team.Privacy) return nil } @@ -65,8 +74,10 @@ func resourceGithubTeamUpdate(d *schema.ResourceData, meta interface{}) error { name := d.Get("name").(string) description := d.Get("description").(string) + privacy := d.Get("privacy").(string) team.Description = &description team.Name = &name + team.Privacy = &privacy team, _, err = client.Organizations.EditTeam(*team.ID, team) if err != nil { diff --git a/builtin/providers/github/resource_github_team_membership.go b/builtin/providers/github/resource_github_team_membership.go index 6dadfc6f50a0..3bd99cbc8da3 100644 --- a/builtin/providers/github/resource_github_team_membership.go +++ b/builtin/providers/github/resource_github_team_membership.go @@ -31,7 +31,7 @@ func resourceGithubTeamMembership() *schema.Resource { Optional: true, ForceNew: true, Default: "member", - ValidateFunc: validateRoleValueFunc([]string{"member", "maintainer"}), + ValidateFunc: validateValueFunc([]string{"member", "maintainer"}), }, }, } diff --git a/builtin/providers/github/resource_github_team_repository.go b/builtin/providers/github/resource_github_team_repository.go index d4ef1ed08669..cc46f66ce86e 100644 --- a/builtin/providers/github/resource_github_team_repository.go +++ b/builtin/providers/github/resource_github_team_repository.go @@ -33,7 +33,7 @@ func resourceGithubTeamRepository() *schema.Resource { Type: schema.TypeString, Optional: true, Default: "pull", - ValidateFunc: validateRoleValueFunc([]string{"pull", "push", "admin"}), + ValidateFunc: validateValueFunc([]string{"pull", "push", "admin"}), }, }, } diff --git a/builtin/providers/github/resource_github_team_test.go b/builtin/providers/github/resource_github_team_test.go index e5429fe632b6..19b58b18c0cf 100644 --- a/builtin/providers/github/resource_github_team_test.go +++ b/builtin/providers/github/resource_github_team_test.go @@ -97,6 +97,7 @@ const testAccGithubTeamConfig = ` resource "github_team" "foo" { name = "foo" description = "Terraform acc test group" + privacy = "secret" } ` @@ -104,5 +105,6 @@ const testAccGithubTeamUpdateConfig = ` resource "github_team" "foo" { name = "foo2" description = "Terraform acc test group - updated" + privacy = "closed" } ` diff --git a/builtin/providers/github/util.go b/builtin/providers/github/util.go index 3f5e2074a6e4..96256a054515 100644 --- a/builtin/providers/github/util.go +++ b/builtin/providers/github/util.go @@ -17,11 +17,11 @@ func fromGithubID(id *int) string { return strconv.Itoa(*id) } -func validateRoleValueFunc(roles []string) schema.SchemaValidateFunc { +func validateValueFunc(values []string) schema.SchemaValidateFunc { return func(v interface{}, k string) (we []string, errors []error) { value := v.(string) valid := false - for _, role := range roles { + for _, role := range values { if value == role { valid = true break @@ -29,7 +29,7 @@ func validateRoleValueFunc(roles []string) schema.SchemaValidateFunc { } if !valid { - errors = append(errors, fmt.Errorf("%s is an invalid Github role type for %s", value, k)) + errors = append(errors, fmt.Errorf("%s is an invalid value for argument %s", value, k)) } return } diff --git a/builtin/providers/github/util_test.go b/builtin/providers/github/util_test.go index 9efd81f7369f..5d58407ca88a 100644 --- a/builtin/providers/github/util_test.go +++ b/builtin/providers/github/util_test.go @@ -23,13 +23,13 @@ func TestAccGithubUtilRole_validation(t *testing.T) { }, } - validationFunc := validateRoleValueFunc([]string{"valid_one", "valid_two"}) + validationFunc := validateValueFunc([]string{"valid_one", "valid_two"}) for _, tc := range cases { - _, errors := validationFunc(tc.Value, "github_membership") + _, errors := validationFunc(tc.Value, "test_arg") if len(errors) != tc.ErrCount { - t.Fatalf("Expected github_membership to trigger a validation error") + t.Fatalf("Expected 1 validation error") } } } diff --git a/website/source/docs/providers/github/r/team.html.markdown b/website/source/docs/providers/github/r/team.html.markdown index 4e4ee13dd4dd..72eabc3274f6 100644 --- a/website/source/docs/providers/github/r/team.html.markdown +++ b/website/source/docs/providers/github/r/team.html.markdown @@ -20,6 +20,7 @@ a new team will be created. When destroyed, that team will be removed. resource "github_team" "some_team" { name = "some-team" description = "Some cool team" + privacy = "closed" } ``` @@ -29,6 +30,8 @@ The following arguments are supported: * `name` - (Required) The name of the team. * `description` - (Optional) A description of the team. +* `privacy` - (Optional) The level of privacy for the team. Must be one of `secret` or `closed`. + Defaults to `secret`. ## Attributes Reference From 35cfb73262561bc58ecd87763798f96fa38c78ca Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 11 Apr 2016 13:10:30 +0100 Subject: [PATCH 050/665] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d574f25d68..e6ec1e6d0135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ IMPROVEMENTS: * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] * provider/docker: Add support for docker run --user option [GH-5300] * provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials [GH-6007] + * provider/github: Add support for privacy to `github_team` [GH-6116] * provider/cloudstack: Deprecate `ipaddress` in favour of `ip_address` in all resources [GH-6010] * provider/openstack: Allow subnets with no gateway [GH-6060] From 3135706d1f9571395a66dbf70437ad03b48be233 Mon Sep 17 00:00:00 2001 From: Hany Fahim Date: Mon, 11 Apr 2016 08:22:01 -0400 Subject: [PATCH 051/665] Update to use setProjectid helper function --- .../cloudstack/resource_cloudstack_port_forward.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go index fbff933c694e..64fd6a3bb95c 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go +++ b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go @@ -213,15 +213,8 @@ func resourceCloudStackPortForwardRead(d *schema.ResourceData, meta interface{}) p.SetIpaddressid(d.Id()) p.SetListall(true) - // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } l, err := cs.Firewall.ListPortForwardingRules(p) From c40f73960e6377d1e864d1417e39eb332010a0dd Mon Sep 17 00:00:00 2001 From: Adam Heeren Date: Wed, 24 Feb 2016 10:39:24 -0500 Subject: [PATCH 052/665] Support for Linked Cloning in vsphere, based off of https://github.com/mkuzmin/terraform-vsphere/tree/6814028be741262a575b41d8577fadde537d6c62 --- .../resource_vsphere_virtual_machine.go | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index be49c99e7652..d5c1fbd65f9a 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -50,6 +50,7 @@ type virtualMachine struct { cluster string resourcePool string datastore string + linkedClone bool vcpu int memoryMb int64 template string @@ -124,6 +125,12 @@ func resourceVSphereVirtualMachine() *schema.Resource { ForceNew: true, }, + "linkedClone": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, "gateway": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -318,6 +325,10 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{ vm.timeZone = v.(string) } + if v, ok := d.GetOk("linkedClone"); ok { + vm.linkedClone = v.(bool) + } + if raw, ok := d.GetOk("dns_suffixes"); ok { for _, v := range raw.([]interface{}) { vm.dnsSuffixes = append(vm.dnsSuffixes, v.(string)) @@ -707,8 +718,15 @@ func buildNetworkDevice(f *find.Finder, label, adapterType string) (*types.Virtu } // buildVMRelocateSpec builds VirtualMachineRelocateSpec to set a place for a new VirtualMachine. -func buildVMRelocateSpec(rp *object.ResourcePool, ds *object.Datastore, vm *object.VirtualMachine, initType string) (types.VirtualMachineRelocateSpec, error) { +func buildVMRelocateSpec(rp *object.ResourcePool, ds *object.Datastore, vm *object.VirtualMachine, linkedClone bool, initType string) (types.VirtualMachineRelocateSpec, error) { var key int + var moveType string + if linkedClone { + moveType = "createNewChildDiskBacking" + } else { + moveType = "moveAllDiskBackingsAndDisallowSharing" + } + log.Printf("[DEBUG] relocate type: [%s]", moveType) devices, err := vm.Device(context.TODO()) if err != nil { @@ -724,8 +742,9 @@ func buildVMRelocateSpec(rp *object.ResourcePool, ds *object.Datastore, vm *obje rpr := rp.Reference() dsr := ds.Reference() return types.VirtualMachineRelocateSpec{ - Datastore: &dsr, - Pool: &rpr, + Datastore: &dsr, + Pool: &rpr, + DiskMoveType: moveType, Disk: []types.VirtualMachineRelocateSpecDiskLocator{ types.VirtualMachineRelocateSpecDiskLocator{ Datastore: dsr, @@ -1099,7 +1118,7 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { } log.Printf("[DEBUG] datastore: %#v", datastore) - relocateSpec, err := buildVMRelocateSpec(resourcePool, datastore, template, vm.hardDisks[0].initType) + relocateSpec, err := buildVMRelocateSpec(resourcePool, datastore, template, vm.linkedClone, vm.hardDisks[0].initType) if err != nil { return err } @@ -1204,6 +1223,17 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { Config: &configSpec, PowerOn: false, } + if vm.linkedClone { + var template_mo mo.VirtualMachine + err = template.Properties(context.TODO(), template.Reference(), []string{"parent", "config.template", "resourcePool", "snapshot", "guest.toolsVersionStatus2", "config.guestFullName"}, &template_mo) + if err != nil { + return fmt.Errorf("Error reading base VM properties: %s", err) + } + if template_mo.Snapshot == nil { + return fmt.Errorf("`linkedClone=true`, but image VM has no snapshots") + } + cloneSpec.Snapshot = template_mo.Snapshot.CurrentSnapshot + } log.Printf("[DEBUG] clone spec: %v", cloneSpec) task, err := template.Clone(context.TODO(), folder, vm.name, cloneSpec) From 5f4a3ec09a275ae195d63b9657c9ccbf61bb40cd Mon Sep 17 00:00:00 2001 From: Adam Heeren Date: Thu, 10 Mar 2016 16:12:33 -0500 Subject: [PATCH 053/665] Creating different config spec based on template OS ID --- .../resource_vsphere_virtual_machine.go | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index d5c1fbd65f9a..a26afde3d609 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net" + "strconv" "strings" "time" @@ -1198,16 +1199,50 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { log.Printf("[DEBUG] virtual machine Extra Config spec: %v", configSpec.ExtraConfig) } - // create CustomizationSpec - customSpec := types.CustomizationSpec{ - Identity: &types.CustomizationLinuxPrep{ + var template_mo mo.VirtualMachine + err = template.Properties(context.TODO(), template.Reference(), []string{"parent", "config.template", "config.guestId", "resourcePool", "snapshot", "guest.toolsVersionStatus2", "config.guestFullName"}, &template_mo) + + var identity_options types.BaseCustomizationIdentitySettings + if strings.HasPrefix(template_mo.Config.GuestId, "win") { + var timeZone int + timeZone, err := strconv.Atoi(vm.timeZone) + if err != nil { + return fmt.Errorf("Error reading base VM properties: %s", err) + } + identity_options = &types.CustomizationSysprep{ + GuiUnattended: types.CustomizationGuiUnattended{ + AutoLogon: false, + AutoLogonCount: 1, + Password: &types.CustomizationPassword{ + PlainText: true, + Value: "NULL", + }, + TimeZone: timeZone, + }, + Identification: types.CustomizationIdentification{}, + UserData: types.CustomizationUserData{ + ComputerName: &types.CustomizationFixedName{ + Name: strings.Split(vm.name, ".")[0], + }, + FullName: "LSTTE", + OrgName: "LSTTE", + ProductId: "ruh roh", + }, + } + } else { + identity_options = &types.CustomizationLinuxPrep{ HostName: &types.CustomizationFixedName{ Name: strings.Split(vm.name, ".")[0], }, Domain: vm.domain, TimeZone: vm.timeZone, HwClockUTC: types.NewBool(true), - }, + } + } + + // create CustomizationSpec + customSpec := types.CustomizationSpec{ + Identity: identity_options, GlobalIPSettings: types.CustomizationGlobalIPSettings{ DnsSuffixList: vm.dnsSuffixes, DnsServerList: vm.dnsServers, @@ -1224,8 +1259,6 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { PowerOn: false, } if vm.linkedClone { - var template_mo mo.VirtualMachine - err = template.Properties(context.TODO(), template.Reference(), []string{"parent", "config.template", "resourcePool", "snapshot", "guest.toolsVersionStatus2", "config.guestFullName"}, &template_mo) if err != nil { return fmt.Errorf("Error reading base VM properties: %s", err) } From 7dfc0a6d1e1702e3e9fb6d4e58cbc741eb37482a Mon Sep 17 00:00:00 2001 From: Adam Heeren Date: Wed, 23 Mar 2016 16:46:33 -0400 Subject: [PATCH 054/665] Added windows clone options in vsphere and documented them --- .../resource_vsphere_virtual_machine.go | 163 ++++++++++++++---- .../vsphere/r/virtual_machine.html.markdown | 11 +- 2 files changed, 136 insertions(+), 38 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index a26afde3d609..cd0ce3ea1384 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -44,25 +44,35 @@ type hardDisk struct { initType string } +//Additional options Vsphere can use clones of windows machines +type windowsOptConfig struct { + productKey string + adminPassword string + domainUser string + domain string + domainUserPassword string +} + type virtualMachine struct { - name string - folder string - datacenter string - cluster string - resourcePool string - datastore string - linkedClone bool - vcpu int - memoryMb int64 - template string - networkInterfaces []networkInterface - hardDisks []hardDisk - gateway string - domain string - timeZone string - dnsSuffixes []string - dnsServers []string - customConfigurations map[string](types.AnyType) + name string + folder string + datacenter string + cluster string + resourcePool string + datastore string + linkedClone bool + vcpu int + memoryMb int64 + template string + networkInterfaces []networkInterface + hardDisks []hardDisk + gateway string + domain string + timeZone string + dnsSuffixes []string + dnsServers []string + windowsOptionalConfig windowsOptConfig + customConfigurations map[string](types.AnyType) } func (v virtualMachine) Path() string { @@ -171,6 +181,44 @@ func resourceVSphereVirtualMachine() *schema.Resource { Optional: true, ForceNew: true, }, + "windows_opt_config": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "product_key": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "admin_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "domain_user": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "domain": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "domain_user_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, "network_interface": &schema.Schema{ Type: schema.TypeList, @@ -386,6 +434,28 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] network_interface init: %v", networks) } + if vL, ok := d.GetOk("windows_opt_config"); ok { + var winOpt windowsOptConfig + custom_configs := (vL.([]interface{}))[0].(map[string]interface{}) + if v, ok := custom_configs["admin_password"].(string); ok && v != "" { + winOpt.adminPassword = v + } + if v, ok := custom_configs["domain"].(string); ok && v != "" { + winOpt.domain = v + } + if v, ok := custom_configs["domain_user"].(string); ok && v != "" { + winOpt.domainUser = v + } + if v, ok := custom_configs["product_key"].(string); ok && v != "" { + winOpt.productKey = v + } + if v, ok := custom_configs["domain_user_password"].(string); ok && v != "" { + winOpt.domainUserPassword = v + } + vm.windowsOptionalConfig = winOpt + log.Printf("[DEBUG] windows config init: %v", winOpt) + } + if vL, ok := d.GetOk("disk"); ok { disks := make([]hardDisk, len(vL.([]interface{}))) for i, v := range vL.([]interface{}) { @@ -1207,27 +1277,46 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { var timeZone int timeZone, err := strconv.Atoi(vm.timeZone) if err != nil { - return fmt.Errorf("Error reading base VM properties: %s", err) + return fmt.Errorf("Error converting TimeZone: %s", err) } - identity_options = &types.CustomizationSysprep{ - GuiUnattended: types.CustomizationGuiUnattended{ - AutoLogon: false, - AutoLogonCount: 1, - Password: &types.CustomizationPassword{ - PlainText: true, - Value: "NULL", - }, - TimeZone: timeZone, - }, - Identification: types.CustomizationIdentification{}, - UserData: types.CustomizationUserData{ - ComputerName: &types.CustomizationFixedName{ - Name: strings.Split(vm.name, ".")[0], - }, - FullName: "LSTTE", - OrgName: "LSTTE", - ProductId: "ruh roh", + + guiUnattended := types.CustomizationGuiUnattended{ + AutoLogon: false, + AutoLogonCount: 1, + TimeZone: timeZone, + } + + customIdentification := types.CustomizationIdentification{} + + userData := types.CustomizationUserData{ + ComputerName: &types.CustomizationFixedName{ + Name: strings.Split(vm.name, ".")[0], }, + ProductId: vm.windowsOptionalConfig.productKey, + FullName: "terraform", + OrgName: "terraform", + } + + if vm.windowsOptionalConfig.domainUserPassword != "" && vm.windowsOptionalConfig.domainUser != "" && vm.windowsOptionalConfig.domain != "" { + customIdentification.DomainAdminPassword = &types.CustomizationPassword{ + PlainText: true, + Value: vm.windowsOptionalConfig.domainUserPassword, + } + customIdentification.DomainAdmin = vm.windowsOptionalConfig.domainUser + customIdentification.JoinDomain = vm.windowsOptionalConfig.domain + } + + if vm.windowsOptionalConfig.adminPassword != "" { + guiUnattended.Password = &types.CustomizationPassword{ + PlainText: true, + Value: vm.windowsOptionalConfig.adminPassword, + } + } + + identity_options = &types.CustomizationSysprep{ + GuiUnattended: guiUnattended, + Identification: customIdentification, + UserData: userData, } } else { identity_options = &types.CustomizationLinuxPrep{ diff --git a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown index 9812a0aed870..92b038ecd354 100644 --- a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown @@ -41,12 +41,14 @@ The following arguments are supported: * `resource_pool` (Optional) The name of a Resource Pool in which to launch the virtual machine * `gateway` - (Optional) Gateway IP address to use for all network interfaces * `domain` - (Optional) A FQDN for the virtual machine; defaults to "vsphere.local" -* `time_zone` - (Optional) The [time zone](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/timezone.html) to set on the virtual machine. Defaults to "Etc/UTC" +* `time_zone` - (Optional) The [Linux](https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/timezone.html) or [Windows](https://msdn.microsoft.com/en-us/library/ms912391.aspx) time zone to set on the virtual machine. Defaults to "Etc/UTC" * `dns_suffixes` - (Optional) List of name resolution suffixes for the virtual network adapter * `dns_servers` - (Optional) List of DNS servers for the virtual network adapter; defaults to 8.8.8.8, 8.8.4.4 * `network_interface` - (Required) Configures virtual network interfaces; see [Network Interfaces](#network-interfaces) below for details. * `disk` - (Required) Configures virtual disks; see [Disks](#disks) below for details * `boot_delay` - (Optional) Time in seconds to wait for machine network to be ready. +* `windows_opt_config` - (Optional) Extra options for clones of Windows machines. +* `linkedClone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not. * `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations. The `network_interface` block supports: @@ -61,6 +63,13 @@ removed in a future version: * `ip_address` - __Deprecated, please use `ipv4_address` instead_. * `subnet_mask` - __Deprecated, please use `ipv4_prefix_length` instead_. +The `windows_opt_config` block supports: + +* `product_key` - (Optional) Serial number for new installation of Windows. This serial number is ignored if the original guest operating system was installed using a volume-licensed CD. +* `admin_password` - (Optional) The password for the new `administrator` account. Omit for passwordless admin (using `""` does not work). +* `domain` - (Optional) Domain that the new machine will be placed into. If `domain`, `domain_user`, and `domain_user_password` are not all set, all three will be ignored. +* `domain_user` - (Optional) User that is a member of the specified domain. +* `domain_user_password` - (Optional) Password for domain user, in plain text. The `disk` block supports: From 338cb956ba329fbc7deb378bd362535b5e6e525b Mon Sep 17 00:00:00 2001 From: Adam Heeren Date: Fri, 8 Apr 2016 08:06:22 -0400 Subject: [PATCH 055/665] Rearranging code to clean up git diff --- builtin/providers/vsphere/resource_vsphere_virtual_machine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index cd0ce3ea1384..008c1e7944fd 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -60,7 +60,6 @@ type virtualMachine struct { cluster string resourcePool string datastore string - linkedClone bool vcpu int memoryMb int64 template string @@ -71,6 +70,7 @@ type virtualMachine struct { timeZone string dnsSuffixes []string dnsServers []string + linkedClone bool windowsOptionalConfig windowsOptConfig customConfigurations map[string](types.AnyType) } From 815c8840a78d3f996508e3c1ba6f71e2b2ed8d83 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Mon, 11 Apr 2016 17:14:19 +0200 Subject: [PATCH 056/665] Refactor the use of names vs IDs for parameters referencing other TF resources We have a curtesy function in place allowing you to specify both a `name` of `ID`. But in order for the graph to be build correctly when you recreate or taint stuff that other resources depend on, we need to reference the `ID` and *not* the `name`. So in order to enforce this and by that help people to not make this mistake unknowingly, I deprecated all the parameters this allies to and changed the logic, docs and tests accordingly. --- .../cloudstack/resource_cloudstack_disk.go | 10 +- .../resource_cloudstack_disk_test.go | 6 +- .../resource_cloudstack_egress_firewall.go | 26 +++++- ...esource_cloudstack_egress_firewall_test.go | 10 +- .../resource_cloudstack_firewall.go | 10 +- .../resource_cloudstack_firewall_test.go | 10 +- .../resource_cloudstack_instance.go | 36 +++++--- .../resource_cloudstack_instance_test.go | 14 +-- .../resource_cloudstack_ipaddress.go | 72 +++++++++------ .../resource_cloudstack_ipaddress_test.go | 10 +- .../resource_cloudstack_loadbalancer_rule.go | 91 ++++++++++++------- ...ource_cloudstack_loadbalancer_rule_test.go | 48 +++++----- .../cloudstack/resource_cloudstack_network.go | 67 ++++++++++---- .../resource_cloudstack_network_acl.go | 32 ++++--- .../resource_cloudstack_network_acl_rule.go | 26 +++++- ...source_cloudstack_network_acl_rule_test.go | 8 +- .../resource_cloudstack_network_acl_test.go | 4 +- .../resource_cloudstack_network_test.go | 4 +- .../cloudstack/resource_cloudstack_nic.go | 83 ++++++++++++++--- .../resource_cloudstack_nic_test.go | 20 ++-- .../resource_cloudstack_port_forward.go | 48 ++++++---- .../resource_cloudstack_port_forward_test.go | 48 ++-------- ...resource_cloudstack_secondary_ipaddress.go | 70 +++++++++++--- ...rce_cloudstack_secondary_ipaddress_test.go | 38 +++++--- .../resource_cloudstack_ssh_keypair.go | 4 + .../resource_cloudstack_ssh_keypair_test.go | 9 +- .../resource_cloudstack_static_nat.go | 33 ++----- .../resource_cloudstack_static_nat_test.go | 19 ++-- .../resource_cloudstack_template.go | 10 +- .../cloudstack/resource_cloudstack_vpc.go | 15 +-- .../resource_cloudstack_vpn_connection.go | 50 ++++++++-- ...resource_cloudstack_vpn_connection_test.go | 12 +-- ...ce_cloudstack_vpn_customer_gateway_test.go | 8 +- .../resource_cloudstack_vpn_gateway.go | 32 +++++-- .../resource_cloudstack_vpn_gateway_test.go | 4 +- .../r/egress_firewall.html.markdown | 9 +- .../cloudstack/r/firewall.html.markdown | 6 +- .../cloudstack/r/instance.html.markdown | 7 +- .../cloudstack/r/ipaddress.html.markdown | 18 +++- .../r/loadbalancer_rule.html.markdown | 27 ++++-- .../cloudstack/r/network.html.markdown | 12 ++- .../cloudstack/r/network_acl.html.markdown | 11 ++- .../r/network_acl_rule.html.markdown | 7 +- .../providers/cloudstack/r/nic.html.markdown | 21 +++-- .../cloudstack/r/port_forward.html.markdown | 13 ++- .../r/secondary_ipaddress.html.markdown | 26 ++++-- .../cloudstack/r/static_nat.html.markdown | 22 ++--- .../cloudstack/r/template.html.markdown | 9 +- .../cloudstack/r/vpn_connection.html.markdown | 14 ++- .../cloudstack/r/vpn_gateway.html.markdown | 7 +- 50 files changed, 742 insertions(+), 454 deletions(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_disk.go b/builtin/providers/cloudstack/resource_cloudstack_disk.go index 63a788f66237..7e5b79b74a31 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_disk.go +++ b/builtin/providers/cloudstack/resource_cloudstack_disk.go @@ -94,14 +94,8 @@ func resourceCloudStackDiskCreate(d *schema.ResourceData, meta interface{}) erro } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // Retrieve the zone ID diff --git a/builtin/providers/cloudstack/resource_cloudstack_disk_test.go b/builtin/providers/cloudstack/resource_cloudstack_disk_test.go index 5eee8ed8dd4c..e22c649f8abc 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_disk_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_disk_test.go @@ -175,7 +175,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -200,7 +200,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -224,7 +224,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true diff --git a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go index 0ff330ef40a2..3744cf8fdbf3 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go +++ b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "strconv" "strings" @@ -20,10 +21,19 @@ func resourceCloudStackEgressFirewall() *schema.Resource { Delete: resourceCloudStackEgressFirewallDelete, Schema: map[string]*schema.Schema{ + "network_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ConflictsWith: []string{"network"}, + }, + "network": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `network_id` field instead", + ConflictsWith: []string{"network_id"}, }, "managed": &schema.Schema{ @@ -99,8 +109,16 @@ func resourceCloudStackEgressFirewallCreate(d *schema.ResourceData, meta interfa return err } + network, ok := d.GetOk("network_id") + if !ok { + network, ok = d.GetOk("network") + } + if !ok { + return errors.New("Either `network_id` or [deprecated] `network` must be provided.") + } + // Retrieve the network ID - networkid, e := retrieveID(cs, "network", d.Get("network").(string)) + networkid, e := retrieveID(cs, "network", network.(string)) if e != nil { return e.Error() } diff --git a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall_test.go b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall_test.go index 07f4e0d8a247..cc640ac951f5 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_egress_firewall_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_egress_firewall_test.go @@ -21,7 +21,7 @@ func TestAccCloudStackEgressFirewall_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackEgressFirewallRulesExist("cloudstack_egress_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_egress_firewall.foo", "network", CLOUDSTACK_NETWORK_1), + "cloudstack_egress_firewall.foo", "network_id", CLOUDSTACK_NETWORK_1), resource.TestCheckResourceAttr( "cloudstack_egress_firewall.foo", "rule.#", "2"), resource.TestCheckResourceAttr( @@ -59,7 +59,7 @@ func TestAccCloudStackEgressFirewall_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackEgressFirewallRulesExist("cloudstack_egress_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_egress_firewall.foo", "network", CLOUDSTACK_NETWORK_1), + "cloudstack_egress_firewall.foo", "network_id", CLOUDSTACK_NETWORK_1), resource.TestCheckResourceAttr( "cloudstack_egress_firewall.foo", "rule.#", "2"), resource.TestCheckResourceAttr( @@ -88,7 +88,7 @@ func TestAccCloudStackEgressFirewall_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackEgressFirewallRulesExist("cloudstack_egress_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_egress_firewall.foo", "network", CLOUDSTACK_NETWORK_1), + "cloudstack_egress_firewall.foo", "network_id", CLOUDSTACK_NETWORK_1), resource.TestCheckResourceAttr( "cloudstack_egress_firewall.foo", "rule.#", "3"), resource.TestCheckResourceAttr( @@ -188,7 +188,7 @@ func testAccCheckCloudStackEgressFirewallDestroy(s *terraform.State) error { var testAccCloudStackEgressFirewall_basic = fmt.Sprintf(` resource "cloudstack_egress_firewall" "foo" { - network = "%s" + network_id = "%s" rule { cidr_list = ["%s/32"] @@ -208,7 +208,7 @@ resource "cloudstack_egress_firewall" "foo" { var testAccCloudStackEgressFirewall_update = fmt.Sprintf(` resource "cloudstack_egress_firewall" "foo" { - network = "%s" + network_id = "%s" rule { cidr_list = ["%s/32", "%s/32"] diff --git a/builtin/providers/cloudstack/resource_cloudstack_firewall.go b/builtin/providers/cloudstack/resource_cloudstack_firewall.go index f10f5a6384b6..3b8ebe13c118 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_firewall.go +++ b/builtin/providers/cloudstack/resource_cloudstack_firewall.go @@ -21,7 +21,7 @@ func resourceCloudStackFirewall() *schema.Resource { Delete: resourceCloudStackFirewallDelete, Schema: map[string]*schema.Schema{ - "ip_address": &schema.Schema{ + "ip_address_id": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, @@ -32,8 +32,8 @@ func resourceCloudStackFirewall() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - Deprecated: "Please use the `ip_address` field instead", - ConflictsWith: []string{"ip_address"}, + Deprecated: "Please use the `ip_address_id` field instead", + ConflictsWith: []string{"ip_address_id"}, }, "managed": &schema.Schema{ @@ -109,12 +109,12 @@ func resourceCloudStackFirewallCreate(d *schema.ResourceData, meta interface{}) return err } - ipaddress, ok := d.GetOk("ip_address") + ipaddress, ok := d.GetOk("ip_address_id") if !ok { ipaddress, ok = d.GetOk("ipaddress") } if !ok { - return errors.New("Either `ip_address` or [deprecated] `ipaddress` must be provided.") + return errors.New("Either `ip_address_id` or [deprecated] `ipaddress` must be provided.") } // Retrieve the ipaddress ID diff --git a/builtin/providers/cloudstack/resource_cloudstack_firewall_test.go b/builtin/providers/cloudstack/resource_cloudstack_firewall_test.go index f7fda8110bbf..1b4f48959b71 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_firewall_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_firewall_test.go @@ -21,7 +21,7 @@ func TestAccCloudStackFirewall_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackFirewallRulesExist("cloudstack_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_firewall.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_firewall.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( "cloudstack_firewall.foo", "rule.#", "2"), resource.TestCheckResourceAttr( @@ -55,7 +55,7 @@ func TestAccCloudStackFirewall_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackFirewallRulesExist("cloudstack_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_firewall.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_firewall.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( "cloudstack_firewall.foo", "rule.#", "2"), resource.TestCheckResourceAttr( @@ -80,7 +80,7 @@ func TestAccCloudStackFirewall_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackFirewallRulesExist("cloudstack_firewall.foo"), resource.TestCheckResourceAttr( - "cloudstack_firewall.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_firewall.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( "cloudstack_firewall.foo", "rule.#", "3"), resource.TestCheckResourceAttr( @@ -174,7 +174,7 @@ func testAccCheckCloudStackFirewallDestroy(s *terraform.State) error { var testAccCloudStackFirewall_basic = fmt.Sprintf(` resource "cloudstack_firewall" "foo" { - ip_address = "%s" + ip_address_id = "%s" rule { cidr_list = ["10.0.0.0/24"] @@ -191,7 +191,7 @@ resource "cloudstack_firewall" "foo" { var testAccCloudStackFirewall_update = fmt.Sprintf(` resource "cloudstack_firewall" "foo" { - ip_address = "%s" + ip_address_id = "%s" rule { cidr_list = ["10.0.0.0/24", "10.0.1.0/24"] diff --git a/builtin/providers/cloudstack/resource_cloudstack_instance.go b/builtin/providers/cloudstack/resource_cloudstack_instance.go index 6408faaa0f09..78e64788ec20 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_instance.go +++ b/builtin/providers/cloudstack/resource_cloudstack_instance.go @@ -4,6 +4,7 @@ import ( "crypto/sha1" "encoding/base64" "encoding/hex" + "errors" "fmt" "log" "strings" @@ -37,12 +38,20 @@ func resourceCloudStackInstance() *schema.Resource { Required: true, }, - "network": &schema.Schema{ + "network_id": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, + "network": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `network_id` field instead", + }, + "ip_address": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -149,11 +158,21 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) } if zone.Networktype == "Advanced" { + network, ok := d.GetOk("network_id") + if !ok { + network, ok = d.GetOk("network") + } + if !ok { + return errors.New( + "Either `network_id` or [deprecated] `network` must be provided when using a zone with network type `advanced`.") + } + // Retrieve the network ID - networkid, e := retrieveID(cs, "network", d.Get("network").(string)) + networkid, e := retrieveID(cs, "network", network.(string)) if e != nil { return e.Error() } + // Set the default network ID p.SetNetworkids([]string{networkid}) } @@ -168,14 +187,8 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // If a keypair is supplied, add it to the parameter struct @@ -240,10 +253,9 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er // Update the config d.Set("name", vm.Name) d.Set("display_name", vm.Displayname) + d.Set("network_id", vm.Nic[0].Networkid) d.Set("ip_address", vm.Nic[0].Ipaddress) - //NB cloudstack sometimes sends back the wrong keypair name, so dont update it - setValueOrID(d, "network", vm.Nic[0].Networkname, vm.Nic[0].Networkid) setValueOrID(d, "service_offering", vm.Serviceofferingname, vm.Serviceofferingid) setValueOrID(d, "template", vm.Templatename, vm.Templateid) setValueOrID(d, "project", vm.Project, vm.Projectid) diff --git a/builtin/providers/cloudstack/resource_cloudstack_instance_test.go b/builtin/providers/cloudstack/resource_cloudstack_instance_test.go index f6416b8cf211..2d9743d30d9e 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_instance_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_instance_test.go @@ -180,8 +180,8 @@ func testAccCheckCloudStackInstanceAttributes( return fmt.Errorf("Bad template: %s", instance.Templatename) } - if instance.Nic[0].Networkname != CLOUDSTACK_NETWORK_1 { - return fmt.Errorf("Bad network: %s", instance.Nic[0].Networkname) + if instance.Nic[0].Networkid != CLOUDSTACK_NETWORK_1 { + return fmt.Errorf("Bad network ID: %s", instance.Nic[0].Networkid) } return nil @@ -234,7 +234,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" user_data = "foobar\nfoo\nbar" @@ -250,7 +250,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-updated" display_name = "terraform-updated" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" user_data = "foobar\nfoo\nbar" @@ -266,7 +266,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" ip_address = "%s" template = "%s" zone = "%s" @@ -287,7 +287,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" ip_address = "%s" template = "%s" zone = "%s" @@ -305,7 +305,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" project = "%s" zone = "%s" diff --git a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go index 4c140639a8f6..2c21d222e02f 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go @@ -16,18 +16,34 @@ func resourceCloudStackIPAddress() *schema.Resource { Delete: resourceCloudStackIPAddressDelete, Schema: map[string]*schema.Schema{ - "network": &schema.Schema{ + "network_id": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, - "vpc": &schema.Schema{ + "network": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `network_id` field instead", + }, + + "vpc_id": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, + "vpc": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `vpc_id` field instead", + }, + "project": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -52,7 +68,11 @@ func resourceCloudStackIPAddressCreate(d *schema.ResourceData, meta interface{}) // Create a new parameter struct p := cs.Address.NewAssociateIpAddressParams() - if network, ok := d.GetOk("network"); ok { + network, ok := d.GetOk("network_id") + if !ok { + network, ok = d.GetOk("network") + } + if ok { // Retrieve the network ID networkid, e := retrieveID(cs, "network", network.(string)) if e != nil { @@ -63,7 +83,11 @@ func resourceCloudStackIPAddressCreate(d *schema.ResourceData, meta interface{}) p.SetNetworkid(networkid) } - if vpc, ok := d.GetOk("vpc"); ok { + vpc, ok := d.GetOk("vpc_id") + if !ok { + vpc, ok = d.GetOk("vpc") + } + if ok { // Retrieve the vpc ID vpcid, e := retrieveID(cs, "vpc", vpc.(string)) if e != nil { @@ -75,14 +99,8 @@ func resourceCloudStackIPAddressCreate(d *schema.ResourceData, meta interface{}) } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // Associate a new IP address @@ -115,24 +133,16 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e // Updated the IP address d.Set("ip_address", ip.Ipaddress) - if _, ok := d.GetOk("network"); ok { - // Get the network details - n, _, err := cs.Network.GetNetworkByID(ip.Associatednetworkid) - if err != nil { - return err - } - - setValueOrID(d, "network", n.Name, ip.Associatednetworkid) + _, networkID := d.GetOk("network_id") + _, network := d.GetOk("network") + if networkID || network { + d.Set("network_id", ip.Associatednetworkid) } - if _, ok := d.GetOk("vpc"); ok { - // Get the VPC details - v, _, err := cs.VPC.GetVPCByID(ip.Vpcid) - if err != nil { - return err - } - - setValueOrID(d, "vpc", v.Name, ip.Vpcid) + _, vpcID := d.GetOk("vpc_id") + _, vpc := d.GetOk("vpc") + if vpcID || vpc { + d.Set("vpc_id", ip.Vpcid) } setValueOrID(d, "project", ip.Project, ip.Projectid) @@ -162,12 +172,14 @@ func resourceCloudStackIPAddressDelete(d *schema.ResourceData, meta interface{}) } func verifyIPAddressParams(d *schema.ResourceData) error { + _, networkID := d.GetOk("network_id") _, network := d.GetOk("network") + _, vpcID := d.GetOk("vpc_id") _, vpc := d.GetOk("vpc") - if network && vpc || !network && !vpc { + if (networkID || network) && (vpcID || vpc) || (!networkID && !network) && (!vpcID && !vpc) { return fmt.Errorf( - "You must supply a value for either (so not both) the 'network' or 'vpc' parameter") + "You must supply a value for either (so not both) the 'network_id' or 'vpc_id' parameter") } return nil diff --git a/builtin/providers/cloudstack/resource_cloudstack_ipaddress_test.go b/builtin/providers/cloudstack/resource_cloudstack_ipaddress_test.go index edf120573f73..6b74e96922d9 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ipaddress_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ipaddress_test.go @@ -42,8 +42,6 @@ func TestAccCloudStackIPAddress_vpc(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackIPAddressExists( "cloudstack_ipaddress.foo", &ipaddr), - resource.TestCheckResourceAttr( - "cloudstack_ipaddress.foo", "vpc", "terraform-vpc"), ), }, }, @@ -83,8 +81,8 @@ func testAccCheckCloudStackIPAddressAttributes( ipaddr *cloudstack.PublicIpAddress) resource.TestCheckFunc { return func(s *terraform.State) error { - if ipaddr.Associatednetworkname != CLOUDSTACK_NETWORK_1 { - return fmt.Errorf("Bad network: %s", ipaddr.Associatednetworkname) + if ipaddr.Associatednetworkid != CLOUDSTACK_NETWORK_1 { + return fmt.Errorf("Bad network ID: %s", ipaddr.Associatednetworkid) } return nil @@ -114,7 +112,7 @@ func testAccCheckCloudStackIPAddressDestroy(s *terraform.State) error { var testAccCloudStackIPAddress_basic = fmt.Sprintf(` resource "cloudstack_ipaddress" "foo" { - network = "%s" + network_id = "%s" }`, CLOUDSTACK_NETWORK_1) var testAccCloudStackIPAddress_vpc = fmt.Sprintf(` @@ -126,7 +124,7 @@ resource "cloudstack_vpc" "foobar" { } resource "cloudstack_ipaddress" "foo" { - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, diff --git a/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule.go b/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule.go index d4f3143ccc48..829d7296e766 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule.go +++ b/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule.go @@ -29,27 +29,34 @@ func resourceCloudStackLoadBalancerRule() *schema.Resource { Computed: true, }, - "ip_address": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ConflictsWith: []string{"ipaddress"}, + "ip_address_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, "ipaddress": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Deprecated: "Please use the `ip_address` field instead", - ConflictsWith: []string{"ip_address"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `ip_address_id` field instead", }, - "network": &schema.Schema{ + "network_id": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, + "network": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `network_id` field instead", + }, + "algorithm": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -67,11 +74,21 @@ func resourceCloudStackLoadBalancerRule() *schema.Resource { ForceNew: true, }, + "member_ids": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + ConflictsWith: []string{"members"}, + }, + "members": &schema.Schema{ - Type: schema.TypeList, - Required: true, - ForceNew: true, - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Deprecated: "Please use the `member_ids` field instead", + ConflictsWith: []string{"member_ids"}, }, }, } @@ -99,23 +116,27 @@ func resourceCloudStackLoadBalancerRuleCreate(d *schema.ResourceData, meta inter p.SetDescription(d.Get("name").(string)) } - // Retrieve the network and the ID - if network, ok := d.GetOk("network"); ok { + network, ok := d.GetOk("network_id") + if !ok { + network, ok = d.GetOk("network") + } + if ok { + // Retrieve the network ID networkid, e := retrieveID(cs, "network", network.(string)) if e != nil { return e.Error() } - // Set the default network ID + // Set the networkid p.SetNetworkid(networkid) } - ipaddress, ok := d.GetOk("ip_address") + ipaddress, ok := d.GetOk("ip_address_id") if !ok { ipaddress, ok = d.GetOk("ipaddress") } if !ok { - return errors.New("Either `ip_address` or [deprecated] `ipaddress` must be provided.") + return errors.New("Either `ip_address_id` or [deprecated] `ipaddress` must be provided.") } // Retrieve the ipaddress ID @@ -135,8 +156,8 @@ func resourceCloudStackLoadBalancerRuleCreate(d *schema.ResourceData, meta inter d.SetId(r.Id) d.SetPartial("name") d.SetPartial("description") - d.SetPartial("ip_address") - d.SetPartial("network") + d.SetPartial("ip_address_id") + d.SetPartial("network_id") d.SetPartial("algorithm") d.SetPartial("private_port") d.SetPartial("public_port") @@ -144,8 +165,16 @@ func resourceCloudStackLoadBalancerRuleCreate(d *schema.ResourceData, meta inter // Create a new parameter struct ap := cs.LoadBalancer.NewAssignToLoadBalancerRuleParams(r.Id) + members, ok := d.GetOk("member_ids") + if !ok { + members, ok = d.GetOk("members") + } + if !ok { + return errors.New("Either `member_ids` or [deprecated] `members` must be provided.") + } + var mbs []string - for _, id := range d.Get("members").([]interface{}) { + for _, id := range members.([]interface{}) { mbs = append(mbs, id.(string)) } @@ -156,9 +185,10 @@ func resourceCloudStackLoadBalancerRuleCreate(d *schema.ResourceData, meta inter return err } + d.SetPartial("member_ids") d.SetPartial("members") - d.Partial(false) + return resourceCloudStackLoadBalancerRuleRead(d, meta) } @@ -180,16 +210,13 @@ func resourceCloudStackLoadBalancerRuleRead(d *schema.ResourceData, meta interfa d.Set("algorithm", lb.Algorithm) d.Set("public_port", lb.Publicport) d.Set("private_port", lb.Privateport) - - setValueOrID(d, "ip_address", lb.Publicip, lb.Publicipid) + d.Set("ip_address_id", lb.Publicipid) // Only set network if user specified it to avoid spurious diffs - if _, ok := d.GetOk("network"); ok { - network, _, err := cs.Network.GetNetworkByID(lb.Networkid) - if err != nil { - return err - } - setValueOrID(d, "network", network.Name, lb.Networkid) + _, networkID := d.GetOk("network_id") + _, network := d.GetOk("network") + if networkID || network { + d.Set("network_id", lb.Networkid) } return nil diff --git a/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule_test.go b/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule_test.go index b34c4f555f59..9d3f6ec1e651 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_loadbalancer_rule_test.go @@ -75,7 +75,7 @@ func TestAccCloudStackLoadBalancerRule_update(t *testing.T) { }) } -func TestAccCloudStackLoadBalancerRule_forcenew(t *testing.T) { +func TestAccCloudStackLoadBalancerRule_forceNew(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -138,7 +138,7 @@ func TestAccCloudStackLoadBalancerRule_vpc(t *testing.T) { }) } -func TestAccCloudStackLoadBalancerRule_vpc_update(t *testing.T) { +func TestAccCloudStackLoadBalancerRule_vpcUpdate(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -243,7 +243,7 @@ resource "cloudstack_instance" "foobar1" { name = "terraform-server1" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -251,11 +251,11 @@ resource "cloudstack_instance" "foobar1" { resource "cloudstack_loadbalancer_rule" "foo" { name = "terraform-lb" - ip_address = "%s" + ip_address_id = "%s" algorithm = "roundrobin" public_port = 80 private_port = 80 - members = ["${cloudstack_instance.foobar1.id}"] + member_ids = ["${cloudstack_instance.foobar1.id}"] } `, CLOUDSTACK_SERVICE_OFFERING_1, @@ -269,7 +269,7 @@ resource "cloudstack_instance" "foobar1" { name = "terraform-server1" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -277,11 +277,11 @@ resource "cloudstack_instance" "foobar1" { resource "cloudstack_loadbalancer_rule" "foo" { name = "terraform-lb-update" - ip_address = "%s" + ip_address_id = "%s" algorithm = "leastconn" public_port = 80 private_port = 80 - members = ["${cloudstack_instance.foobar1.id}"] + member_ids = ["${cloudstack_instance.foobar1.id}"] } `, CLOUDSTACK_SERVICE_OFFERING_1, @@ -295,7 +295,7 @@ resource "cloudstack_instance" "foobar1" { name = "terraform-server1" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -303,11 +303,11 @@ resource "cloudstack_instance" "foobar1" { resource "cloudstack_loadbalancer_rule" "foo" { name = "terraform-lb-update" - ip_address = "%s" + ip_address_id = "%s" algorithm = "leastconn" public_port = 443 private_port = 443 - members = ["${cloudstack_instance.foobar1.id}"] + member_ids = ["${cloudstack_instance.foobar1.id}"] } `, CLOUDSTACK_SERVICE_OFFERING_1, @@ -328,19 +328,19 @@ resource "cloudstack_network" "foo" { name = "terraform-network" cidr = "%s" network_offering = "%s" - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" zone = "${cloudstack_vpc.foobar.zone}" } resource "cloudstack_ipaddress" "foo" { - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" } resource "cloudstack_instance" "foobar1" { name = "terraform-server1" display_name = "terraform" service_offering= "%s" - network = "${cloudstack_network.foo.name}" + network_id = "${cloudstack_network.foo.id}" template = "%s" zone = "${cloudstack_network.foo.zone}" expunge = true @@ -348,12 +348,12 @@ resource "cloudstack_instance" "foobar1" { resource "cloudstack_loadbalancer_rule" "foo" { name = "terraform-lb" - ip_address = "${cloudstack_ipaddress.foo.ip_address}" + ip_address_id = "${cloudstack_ipaddress.foo.id}" algorithm = "roundrobin" - network = "${cloudstack_network.foo.id}" + network_id = "${cloudstack_network.foo.id}" public_port = 80 private_port = 80 - members = ["${cloudstack_instance.foobar1.id}"] + member_ids = ["${cloudstack_instance.foobar1.id}"] }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, @@ -375,19 +375,19 @@ resource "cloudstack_network" "foo" { name = "terraform-network" cidr = "%s" network_offering = "%s" - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" zone = "${cloudstack_vpc.foobar.zone}" } resource "cloudstack_ipaddress" "foo" { - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" } resource "cloudstack_instance" "foobar1" { name = "terraform-server1" display_name = "terraform" service_offering= "%s" - network = "${cloudstack_network.foo.name}" + network_id = "${cloudstack_network.foo.id}" template = "%s" zone = "${cloudstack_network.foo.zone}" expunge = true @@ -397,7 +397,7 @@ resource "cloudstack_instance" "foobar2" { name = "terraform-server2" display_name = "terraform" service_offering= "%s" - network = "${cloudstack_network.foo.name}" + network_id = "${cloudstack_network.foo.id}" template = "%s" zone = "${cloudstack_network.foo.zone}" expunge = true @@ -405,12 +405,12 @@ resource "cloudstack_instance" "foobar2" { resource "cloudstack_loadbalancer_rule" "foo" { name = "terraform-lb-update" - ip_address = "${cloudstack_ipaddress.foo.ip_address}" + ip_address_id = "${cloudstack_ipaddress.foo.id}" algorithm = "leastconn" - network = "${cloudstack_network.foo.id}" + network_id = "${cloudstack_network.foo.id}" public_port = 443 private_port = 443 - members = ["${cloudstack_instance.foobar1.id}", "${cloudstack_instance.foobar2.id}"] + member_ids = ["${cloudstack_instance.foobar1.id}", "${cloudstack_instance.foobar2.id}"] }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, diff --git a/builtin/providers/cloudstack/resource_cloudstack_network.go b/builtin/providers/cloudstack/resource_cloudstack_network.go index 261d0ec508d1..c8df5187d6d5 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network.go @@ -68,16 +68,33 @@ func resourceCloudStackNetwork() *schema.Resource { ForceNew: true, }, - "vpc": &schema.Schema{ + "vpc_id": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, + "vpc": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `vpc_id` field instead", + }, + + "acl_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ConflictsWith: []string{"aclid"}, + }, + "aclid": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `acl_id` field instead", }, "project": &schema.Schema{ @@ -138,34 +155,34 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e } // Check is this network needs to be created in a VPC - vpc := d.Get("vpc").(string) - if vpc != "" { + vpc, ok := d.GetOk("vpc_id") + if !ok { + vpc, ok = d.GetOk("vpc") + } + if ok { // Retrieve the vpc ID - vpcid, e := retrieveID(cs, "vpc", vpc) + vpcid, e := retrieveID(cs, "vpc", vpc.(string)) if e != nil { return e.Error() } - // Set the vpc ID + // Set the vpcid p.SetVpcid(vpcid) // Since we're in a VPC, check if we want to assiciate an ACL list - aclid := d.Get("aclid").(string) - if aclid != "" { + aclid, ok := d.GetOk("acl_id") + if !ok { + aclid, ok = d.GetOk("acl") + } + if ok { // Set the acl ID - p.SetAclid(aclid) + p.SetAclid(aclid.(string)) } } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // Create the new network @@ -205,6 +222,18 @@ func resourceCloudStackNetworkRead(d *schema.ResourceData, meta interface{}) err d.Set("cidr", n.Cidr) d.Set("gateway", n.Gateway) + _, vpcID := d.GetOk("vpc_id") + _, vpc := d.GetOk("vpc") + if vpcID || vpc { + d.Set("vpc_id", n.Vpcid) + } + + _, aclID := d.GetOk("acl_id") + _, acl := d.GetOk("aclid") + if aclID || acl { + d.Set("acl_id", n.Aclid) + } + // Read the tags and store them in a map tags := make(map[string]interface{}) for item := range n.Tags { diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl.go index 2504b762bfab..c39c695d9b76 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "log" "strings" @@ -29,11 +30,19 @@ func resourceCloudStackNetworkACL() *schema.Resource { ForceNew: true, }, - "vpc": &schema.Schema{ + "vpc_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + + "vpc": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `vpc_id` field instead", + }, }, } } @@ -43,8 +52,16 @@ func resourceCloudStackNetworkACLCreate(d *schema.ResourceData, meta interface{} name := d.Get("name").(string) + vpc, ok := d.GetOk("vpc_id") + if !ok { + vpc, ok = d.GetOk("vpc") + } + if !ok { + return errors.New("Either `vpc_id` or [deprecated] `vpc` must be provided.") + } + // Retrieve the vpc ID - vpcid, e := retrieveID(cs, "vpc", d.Get("vpc").(string)) + vpcid, e := retrieveID(cs, "vpc", vpc.(string)) if e != nil { return e.Error() } @@ -88,14 +105,7 @@ func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{}) d.Set("name", f.Name) d.Set("description", f.Description) - - // Get the VPC details - v, _, err := cs.VPC.GetVPCByID(f.Vpcid) - if err != nil { - return err - } - - setValueOrID(d, "vpc", v.Name, v.Id) + d.Set("vpc_id", f.Vpcid) return nil } diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go index 14e39d99c9e7..88de58f911ff 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "strconv" "strings" @@ -20,10 +21,19 @@ func resourceCloudStackNetworkACLRule() *schema.Resource { Delete: resourceCloudStackNetworkACLRuleDelete, Schema: map[string]*schema.Schema{ + "acl_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ConflictsWith: []string{"aclid"}, + }, + "aclid": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `acl_id` field instead", + ConflictsWith: []string{"acl_id"}, }, "managed": &schema.Schema{ @@ -109,8 +119,16 @@ func resourceCloudStackNetworkACLRuleCreate(d *schema.ResourceData, meta interfa return err } + aclid, ok := d.GetOk("acl_id") + if !ok { + aclid, ok = d.GetOk("aclid") + } + if !ok { + return errors.New("Either `acl_id` or [deprecated] `aclid` must be provided.") + } + // We need to set this upfront in order to be able to save a partial state - d.SetId(d.Get("aclid").(string)) + d.SetId(aclid.(string)) // Create all rules that are configured if nrs := d.Get("rule").(*schema.Set); nrs.Len() > 0 { diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule_test.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule_test.go index 862418f704e3..3fb978172a75 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl_rule_test.go @@ -219,11 +219,11 @@ resource "cloudstack_vpc" "foobar" { resource "cloudstack_network_acl" "foo" { name = "terraform-acl" description = "terraform-acl-text" - vpc = "${cloudstack_vpc.foobar.id}" + vpc_id = "${cloudstack_vpc.foobar.id}" } resource "cloudstack_network_acl_rule" "foo" { - aclid = "${cloudstack_network_acl.foo.id}" + acl_id = "${cloudstack_network_acl.foo.id}" rule { action = "allow" @@ -263,11 +263,11 @@ resource "cloudstack_vpc" "foobar" { resource "cloudstack_network_acl" "foo" { name = "terraform-acl" description = "terraform-acl-text" - vpc = "${cloudstack_vpc.foobar.id}" + vpc_id = "${cloudstack_vpc.foobar.id}" } resource "cloudstack_network_acl_rule" "foo" { - aclid = "${cloudstack_network_acl.foo.id}" + acl_id = "${cloudstack_network_acl.foo.id}" rule { action = "deny" diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl_test.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl_test.go index c8a58a8fe6ee..d6431c39956b 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl_test.go @@ -22,8 +22,6 @@ func TestAccCloudStackNetworkACL_basic(t *testing.T) { testAccCheckCloudStackNetworkACLExists( "cloudstack_network_acl.foo", &acl), testAccCheckCloudStackNetworkACLBasicAttributes(&acl), - resource.TestCheckResourceAttr( - "cloudstack_network_acl.foo", "vpc", "terraform-vpc"), ), }, }, @@ -106,7 +104,7 @@ resource "cloudstack_vpc" "foobar" { resource "cloudstack_network_acl" "foo" { name = "terraform-acl" description = "terraform-acl-text" - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_test.go b/builtin/providers/cloudstack/resource_cloudstack_network_test.go index 3bc1744b9bf7..49400dad7e8b 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_test.go @@ -44,8 +44,6 @@ func TestAccCloudStackNetwork_vpc(t *testing.T) { testAccCheckCloudStackNetworkExists( "cloudstack_network.foo", &network), testAccCheckCloudStackNetworkVPCAttributes(&network), - resource.TestCheckResourceAttr( - "cloudstack_network.foo", "vpc", "terraform-vpc"), ), }, }, @@ -187,7 +185,7 @@ resource "cloudstack_network" "foo" { name = "terraform-network" cidr = "%s" network_offering = "%s" - vpc = "${cloudstack_vpc.foobar.name}" + vpc_id = "${cloudstack_vpc.foobar.id}" zone = "${cloudstack_vpc.foobar.zone}" }`, CLOUDSTACK_VPC_CIDR_1, diff --git a/builtin/providers/cloudstack/resource_cloudstack_nic.go b/builtin/providers/cloudstack/resource_cloudstack_nic.go index 6902f197e5fe..0baae852ead0 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_nic.go +++ b/builtin/providers/cloudstack/resource_cloudstack_nic.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "log" "strings" @@ -16,12 +17,20 @@ func resourceCloudStackNIC() *schema.Resource { Delete: resourceCloudStackNICDelete, Schema: map[string]*schema.Schema{ - "network": &schema.Schema{ + "network_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + "network": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `network_id` field instead", + }, + "ip_address": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -32,16 +41,23 @@ func resourceCloudStackNIC() *schema.Resource { "ipaddress": &schema.Schema{ Type: schema.TypeString, Optional: true, - Computed: true, ForceNew: true, Deprecated: "Please use the `ip_address` field instead", }, - "virtual_machine": &schema.Schema{ + "virtual_machine_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + + "virtual_machine": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `virtual_machine_id` field instead", + }, }, } } @@ -49,14 +65,31 @@ func resourceCloudStackNIC() *schema.Resource { func resourceCloudStackNICCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + network, ok := d.GetOk("network_id") + if !ok { + network, ok = d.GetOk("network") + } + if !ok { + return errors.New("Either `network_id` or [deprecated] `network` must be provided.") + } + // Retrieve the network ID - networkid, e := retrieveID(cs, "network", d.Get("network").(string)) + networkid, e := retrieveID(cs, "network", network.(string)) if e != nil { return e.Error() } + virtualmachine, ok := d.GetOk("virtual_machine_id") + if !ok { + virtualmachine, ok = d.GetOk("virtual_machine") + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", d.Get("virtual_machine").(string)) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) if e != nil { return e.Error() } @@ -89,7 +122,7 @@ func resourceCloudStackNICCreate(d *schema.ResourceData, meta interface{}) error } if !found { - return fmt.Errorf("Could not find NIC ID for network: %s", d.Get("network").(string)) + return fmt.Errorf("Could not find NIC ID for network ID: %s", networkid) } return resourceCloudStackNICRead(d, meta) @@ -98,8 +131,23 @@ func resourceCloudStackNICCreate(d *schema.ResourceData, meta interface{}) error func resourceCloudStackNICRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + virtualmachine, ok := d.GetOk("virtual_machine_id") + if !ok { + virtualmachine, ok = d.GetOk("virtual_machine") + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + + // Retrieve the virtual_machine ID + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) + if e != nil { + return e.Error() + } + // Get the virtual machine details - vm, count, err := cs.VirtualMachine.GetVirtualMachineByName(d.Get("virtual_machine").(string)) + vm, count, err := cs.VirtualMachine.GetVirtualMachineByID(virtualmachineid) if err != nil { if count == 0 { log.Printf("[DEBUG] Instance %s does no longer exist", d.Get("virtual_machine").(string)) @@ -115,15 +163,15 @@ func resourceCloudStackNICRead(d *schema.ResourceData, meta interface{}) error { for _, n := range vm.Nic { if n.Id == d.Id() { d.Set("ip_address", n.Ipaddress) - setValueOrID(d, "network", n.Networkname, n.Networkid) - setValueOrID(d, "virtual_machine", vm.Name, vm.Id) + d.Set("network_id", n.Networkid) + d.Set("virtual_machine_id", vm.Id) found = true break } } if !found { - log.Printf("[DEBUG] NIC for network %s does no longer exist", d.Get("network").(string)) + log.Printf("[DEBUG] NIC for network ID %s does no longer exist", d.Get("network_id").(string)) d.SetId("") } @@ -133,8 +181,17 @@ func resourceCloudStackNICRead(d *schema.ResourceData, meta interface{}) error { func resourceCloudStackNICDelete(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + virtualmachine, ok := d.GetOk("virtual_machine_id") + if !ok { + virtualmachine, ok = d.GetOk("virtual_machine") + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", d.Get("virtual_machine").(string)) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) if e != nil { return e.Error() } diff --git a/builtin/providers/cloudstack/resource_cloudstack_nic_test.go b/builtin/providers/cloudstack/resource_cloudstack_nic_test.go index 249c02d89d9c..a7e6fcff6d30 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_nic_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_nic_test.go @@ -103,8 +103,8 @@ func testAccCheckCloudStackNICAttributes( nic *cloudstack.Nic) resource.TestCheckFunc { return func(s *terraform.State) error { - if nic.Networkname != CLOUDSTACK_2ND_NIC_NETWORK { - return fmt.Errorf("Bad network: %s", nic.Networkname) + if nic.Networkid != CLOUDSTACK_2ND_NIC_NETWORK { + return fmt.Errorf("Bad network ID: %s", nic.Networkid) } return nil @@ -115,8 +115,8 @@ func testAccCheckCloudStackNICIPAddress( nic *cloudstack.Nic) resource.TestCheckFunc { return func(s *terraform.State) error { - if nic.Networkname != CLOUDSTACK_2ND_NIC_NETWORK { - return fmt.Errorf("Bad network: %s", nic.Networkname) + if nic.Networkid != CLOUDSTACK_2ND_NIC_NETWORK { + return fmt.Errorf("Bad network ID: %s", nic.Networkname) } if nic.Ipaddress != CLOUDSTACK_2ND_NIC_IPADDRESS { @@ -154,15 +154,15 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true } resource "cloudstack_nic" "foo" { - network = "%s" - virtual_machine = "${cloudstack_instance.foobar.name}" + network_id = "%s" + virtual_machine_id = "${cloudstack_instance.foobar.id}" }`, CLOUDSTACK_SERVICE_OFFERING_1, CLOUDSTACK_NETWORK_1, @@ -175,16 +175,16 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true } resource "cloudstack_nic" "foo" { - network = "%s" + network_id = "%s" ip_address = "%s" - virtual_machine = "${cloudstack_instance.foobar.name}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" }`, CLOUDSTACK_SERVICE_OFFERING_1, CLOUDSTACK_NETWORK_1, diff --git a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go index 64fd6a3bb95c..ca84f91bab48 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_port_forward.go +++ b/builtin/providers/cloudstack/resource_cloudstack_port_forward.go @@ -22,7 +22,7 @@ func resourceCloudStackPortForward() *schema.Resource { Delete: resourceCloudStackPortForwardDelete, Schema: map[string]*schema.Schema{ - "ip_address": &schema.Schema{ + "ip_address_id": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, @@ -33,8 +33,8 @@ func resourceCloudStackPortForward() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - Deprecated: "Please use the `ip_address` field instead", - ConflictsWith: []string{"ip_address"}, + Deprecated: "Please use the `ip_address_id` field instead", + ConflictsWith: []string{"ip_address_id"}, }, "managed": &schema.Schema{ @@ -69,9 +69,15 @@ func resourceCloudStackPortForward() *schema.Resource { Required: true, }, - "virtual_machine": &schema.Schema{ + "virtual_machine_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + }, + + "virtual_machine": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Deprecated: "Please use the `virtual_machine_id` field instead", }, "uuid": &schema.Schema{ @@ -88,12 +94,12 @@ func resourceCloudStackPortForward() *schema.Resource { func resourceCloudStackPortForwardCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) - ipaddress, ok := d.GetOk("ip_address") + ipaddress, ok := d.GetOk("ip_address_id") if !ok { ipaddress, ok = d.GetOk("ipaddress") } if !ok { - return errors.New("Either `ip_address` or [deprecated] `ipaddress` must be provided.") + return errors.New("Either `ip_address_id` or [deprecated] `ipaddress` must be provided.") } // Retrieve the ipaddress ID @@ -173,8 +179,17 @@ func createPortForward( return err } + virtualmachine, ok := forward["virtual_machine_id"] + if !ok { + virtualmachine, ok = forward["virtual_machine"] + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", forward["virtual_machine"].(string)) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) if e != nil { return e.Error() } @@ -265,12 +280,7 @@ func resourceCloudStackPortForwardRead(d *schema.ResourceData, meta interface{}) forward["protocol"] = f.Protocol forward["private_port"] = privPort forward["public_port"] = pubPort - - if isID(forward["virtual_machine"].(string)) { - forward["virtual_machine"] = f.Virtualmachineid - } else { - forward["virtual_machine"] = f.Virtualmachinename - } + forward["virtual_machine_id"] = f.Virtualmachineid forwards.Add(forward) } @@ -282,11 +292,11 @@ func resourceCloudStackPortForwardRead(d *schema.ResourceData, meta interface{}) for uuid := range forwardMap { // Make a dummy forward to hold the unknown UUID forward := map[string]interface{}{ - "protocol": uuid, - "private_port": 0, - "public_port": 0, - "virtual_machine": uuid, - "uuid": uuid, + "protocol": uuid, + "private_port": 0, + "public_port": 0, + "virtual_machine_id": uuid, + "uuid": uuid, } // Add the dummy forward to the forwards set diff --git a/builtin/providers/cloudstack/resource_cloudstack_port_forward_test.go b/builtin/providers/cloudstack/resource_cloudstack_port_forward_test.go index 8e9104ea13fd..f9038b21c839 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_port_forward_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_port_forward_test.go @@ -21,15 +21,9 @@ func TestAccCloudStackPortForward_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackPortForwardsExist("cloudstack_port_forward.foo"), resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_port_forward.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.protocol", "tcp"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.private_port", "443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.public_port", "8443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.virtual_machine", "terraform-test"), + "cloudstack_port_forward.foo", "forward.#", "1"), ), }, }, @@ -47,17 +41,9 @@ func TestAccCloudStackPortForward_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackPortForwardsExist("cloudstack_port_forward.foo"), resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_port_forward.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( "cloudstack_port_forward.foo", "forward.#", "1"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.protocol", "tcp"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.private_port", "443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.public_port", "8443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.virtual_machine", "terraform-test"), ), }, @@ -66,25 +52,9 @@ func TestAccCloudStackPortForward_update(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackPortForwardsExist("cloudstack_port_forward.foo"), resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "ip_address", CLOUDSTACK_PUBLIC_IPADDRESS), + "cloudstack_port_forward.foo", "ip_address_id", CLOUDSTACK_PUBLIC_IPADDRESS), resource.TestCheckResourceAttr( "cloudstack_port_forward.foo", "forward.#", "2"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.260687715.protocol", "tcp"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.260687715.private_port", "80"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.260687715.public_port", "8080"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.260687715.virtual_machine", "terraform-test"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.protocol", "tcp"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.private_port", "443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.public_port", "8443"), - resource.TestCheckResourceAttr( - "cloudstack_port_forward.foo", "forward.952396423.virtual_machine", "terraform-test"), ), }, }, @@ -161,13 +131,13 @@ resource "cloudstack_instance" "foobar" { } resource "cloudstack_port_forward" "foo" { - ip_address = "%s" + ip_address_id = "%s" forward { protocol = "tcp" private_port = 443 public_port = 8443 - virtual_machine = "${cloudstack_instance.foobar.name}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" } }`, CLOUDSTACK_SERVICE_OFFERING_1, @@ -187,20 +157,20 @@ resource "cloudstack_instance" "foobar" { } resource "cloudstack_port_forward" "foo" { - ip_address = "%s" + ip_address_id = "%s" forward { protocol = "tcp" private_port = 443 public_port = 8443 - virtual_machine = "${cloudstack_instance.foobar.name}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" } forward { protocol = "tcp" private_port = 80 public_port = 8080 - virtual_machine = "${cloudstack_instance.foobar.name}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" } }`, CLOUDSTACK_SERVICE_OFFERING_1, diff --git a/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress.go b/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress.go index cac479791e9e..a9940fd4c14a 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress.go +++ b/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "log" "strings" @@ -26,23 +27,37 @@ func resourceCloudStackSecondaryIPAddress() *schema.Resource { "ipaddress": &schema.Schema{ Type: schema.TypeString, Optional: true, - Computed: true, ForceNew: true, Deprecated: "Please use the `ip_address` field instead", }, - "nicid": &schema.Schema{ + "nic_id": &schema.Schema{ Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, - "virtual_machine": &schema.Schema{ + "nicid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `nic_id` field instead", + }, + + "virtual_machine_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + + "virtual_machine": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `virtual_machine_id` field instead", + }, }, } } @@ -50,10 +65,22 @@ func resourceCloudStackSecondaryIPAddress() *schema.Resource { func resourceCloudStackSecondaryIPAddressCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) - nicid := d.Get("nicid").(string) - if nicid == "" { + nicid, ok := d.GetOk("nic_id") + if !ok { + nicid, ok = d.GetOk("nicid") + } + if !ok { + virtualmachine, ok := d.GetOk("virtual_machine_id") + if !ok { + virtualmachine, ok = d.GetOk("virtual_machine") + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", d.Get("virtual_machine").(string)) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) if e != nil { return e.Error() } @@ -62,7 +89,7 @@ func resourceCloudStackSecondaryIPAddressCreate(d *schema.ResourceData, meta int vm, count, err := cs.VirtualMachine.GetVirtualMachineByID(virtualmachineid) if err != nil { if count == 0 { - log.Printf("[DEBUG] Instance %s does no longer exist", d.Get("virtual_machine").(string)) + log.Printf("[DEBUG] Virtual Machine %s does no longer exist", virtualmachineid) d.SetId("") return nil } @@ -73,7 +100,7 @@ func resourceCloudStackSecondaryIPAddressCreate(d *schema.ResourceData, meta int } // Create a new parameter struct - p := cs.Nic.NewAddIpToNicParams(nicid) + p := cs.Nic.NewAddIpToNicParams(nicid.(string)) // If there is a ipaddres supplied, add it to the parameter struct ipaddress, ok := d.GetOk("ip_address") @@ -97,8 +124,17 @@ func resourceCloudStackSecondaryIPAddressCreate(d *schema.ResourceData, meta int func resourceCloudStackSecondaryIPAddressRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + virtualmachine, ok := d.GetOk("virtual_machine_id") + if !ok { + virtualmachine, ok = d.GetOk("virtual_machine") + } + if !ok { + return errors.New( + "Either `virtual_machine_id` or [deprecated] `virtual_machine` must be provided.") + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", d.Get("virtual_machine").(string)) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine.(string)) if e != nil { return e.Error() } @@ -107,20 +143,23 @@ func resourceCloudStackSecondaryIPAddressRead(d *schema.ResourceData, meta inter vm, count, err := cs.VirtualMachine.GetVirtualMachineByID(virtualmachineid) if err != nil { if count == 0 { - log.Printf("[DEBUG] Instance %s does no longer exist", d.Get("virtual_machine").(string)) + log.Printf("[DEBUG] Virtual Machine %s does no longer exist", virtualmachineid) d.SetId("") return nil } return err } - nicid := d.Get("nicid").(string) - if nicid == "" { + nicid, ok := d.GetOk("nic_id") + if !ok { + nicid, ok = d.GetOk("nicid") + } + if !ok { nicid = vm.Nic[0].Id } p := cs.Nic.NewListNicsParams(virtualmachineid) - p.SetNicid(nicid) + p.SetNicid(nicid.(string)) l, err := cs.Nic.ListNics(p) if err != nil { @@ -140,7 +179,8 @@ func resourceCloudStackSecondaryIPAddressRead(d *schema.ResourceData, meta inter for _, ip := range l.Nics[0].Secondaryip { if ip.Id == d.Id() { d.Set("ip_address", ip.Ipaddress) - d.Set("nicid", l.Nics[0].Id) + d.Set("nic_id", l.Nics[0].Id) + d.Set("virtual_machine_id", l.Nics[0].Virtualmachineid) return nil } } diff --git a/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress_test.go b/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress_test.go index 8b9614831ea3..879ebd4a1e3e 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_secondary_ipaddress_test.go @@ -64,9 +64,13 @@ func testAccCheckCloudStackSecondaryIPAddressExists( cs := testAccProvider.Meta().(*cloudstack.CloudStackClient) + virtualmachine, ok := rs.Primary.Attributes["virtual_machine_id"] + if !ok { + virtualmachine, ok = rs.Primary.Attributes["virtual_machine"] + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID( - cs, "virtual_machine", rs.Primary.Attributes["virtual_machine"]) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine) if e != nil { return e.Error() } @@ -80,8 +84,11 @@ func testAccCheckCloudStackSecondaryIPAddressExists( return err } - nicid := rs.Primary.Attributes["nicid"] - if nicid == "" { + nicid, ok := rs.Primary.Attributes["nic_id"] + if !ok { + nicid, ok = rs.Primary.Attributes["nicid"] + } + if !ok { nicid = vm.Nic[0].Id } @@ -136,9 +143,13 @@ func testAccCheckCloudStackSecondaryIPAddressDestroy(s *terraform.State) error { return fmt.Errorf("No IP address ID is set") } + virtualmachine, ok := rs.Primary.Attributes["virtual_machine_id"] + if !ok { + virtualmachine, ok = rs.Primary.Attributes["virtual_machine"] + } + // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID( - cs, "virtual_machine", rs.Primary.Attributes["virtual_machine"]) + virtualmachineid, e := retrieveID(cs, "virtual_machine", virtualmachine) if e != nil { return e.Error() } @@ -152,8 +163,11 @@ func testAccCheckCloudStackSecondaryIPAddressDestroy(s *terraform.State) error { return err } - nicid := rs.Primary.Attributes["nicid"] - if nicid == "" { + nicid, ok := rs.Primary.Attributes["nic_id"] + if !ok { + nicid, ok = rs.Primary.Attributes["nicid"] + } + if !ok { nicid = vm.Nic[0].Id } @@ -189,14 +203,14 @@ var testAccCloudStackSecondaryIPAddress_basic = fmt.Sprintf(` resource "cloudstack_instance" "foobar" { name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true } resource "cloudstack_secondary_ipaddress" "foo" { - virtual_machine = "${cloudstack_instance.foobar.id}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" } `, CLOUDSTACK_SERVICE_OFFERING_1, @@ -208,7 +222,7 @@ var testAccCloudStackSecondaryIPAddress_fixedIP = fmt.Sprintf(` resource "cloudstack_instance" "foobar" { name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" expunge = true @@ -216,7 +230,7 @@ resource "cloudstack_instance" "foobar" { resource "cloudstack_secondary_ipaddress" "foo" { ip_address = "%s" - virtual_machine = "${cloudstack_instance.foobar.id}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" }`, CLOUDSTACK_SERVICE_OFFERING_1, CLOUDSTACK_NETWORK_1, diff --git a/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair.go b/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair.go index a418c4cf65ca..508077c4121d 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair.go @@ -63,6 +63,7 @@ func resourceCloudStackSSHKeyPairCreate(d *schema.ResourceData, meta interface{} p := cs.SSH.NewRegisterSSHKeyPairParams(name, string(key)) + // If there is a project supplied, we retrieve and set the project id if err := setProjectid(p, cs, d); err != nil { return err } @@ -75,6 +76,7 @@ func resourceCloudStackSSHKeyPairCreate(d *schema.ResourceData, meta interface{} // No key supplied, must create one and return the private key p := cs.SSH.NewCreateSSHKeyPairParams(name) + // If there is a project supplied, we retrieve and set the project id if err := setProjectid(p, cs, d); err != nil { return err } @@ -100,6 +102,7 @@ func resourceCloudStackSSHKeyPairRead(d *schema.ResourceData, meta interface{}) p := cs.SSH.NewListSSHKeyPairsParams() p.SetName(d.Id()) + // If there is a project supplied, we retrieve and set the project id if err := setProjectid(p, cs, d); err != nil { return err } @@ -127,6 +130,7 @@ func resourceCloudStackSSHKeyPairDelete(d *schema.ResourceData, meta interface{} // Create a new parameter struct p := cs.SSH.NewDeleteSSHKeyPairParams(d.Id()) + // If there is a project supplied, we retrieve and set the project id if err := setProjectid(p, cs, d); err != nil { return err } diff --git a/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair_test.go b/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair_test.go index ba70518d5b36..e367d1a73a39 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ssh_keypair_test.go @@ -146,12 +146,11 @@ func testAccCheckCloudStackSSHKeyPairDestroy(s *terraform.State) error { if err != nil { return err } - if list.Count != 1 { - return fmt.Errorf("Found more Key pair %s still exists", rs.Primary.ID) - } - if list.SSHKeyPairs[0].Name == rs.Primary.ID { - return fmt.Errorf("Key pair %s still exists", rs.Primary.ID) + for _, keyPair := range list.SSHKeyPairs { + if keyPair.Name == rs.Primary.ID { + return fmt.Errorf("Key pair %s still exists", rs.Primary.ID) + } } } diff --git a/builtin/providers/cloudstack/resource_cloudstack_static_nat.go b/builtin/providers/cloudstack/resource_cloudstack_static_nat.go index 0f7d7a439bd8..b96991eef0f2 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_static_nat.go +++ b/builtin/providers/cloudstack/resource_cloudstack_static_nat.go @@ -17,20 +17,20 @@ func resourceCloudStackStaticNAT() *schema.Resource { Delete: resourceCloudStackStaticNATDelete, Schema: map[string]*schema.Schema{ - "ipaddress": &schema.Schema{ + "ip_address_id": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, - "network": &schema.Schema{ + "network_id": &schema.Schema{ Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, - "virtual_machine": &schema.Schema{ + "virtual_machine_id": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, @@ -49,29 +49,14 @@ func resourceCloudStackStaticNAT() *schema.Resource { func resourceCloudStackStaticNATCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) - // Retrieve the ipaddress ID - ipaddressid, e := retrieveID(cs, "ipaddress", d.Get("ipaddress").(string)) - if e != nil { - return e.Error() - } - - // Retrieve the virtual_machine ID - virtualmachineid, e := retrieveID(cs, "virtual_machine", d.Get("virtual_machine").(string)) - if e != nil { - return e.Error() - } + ipaddressid := d.Get("ip_address_id").(string) + virtualmachineid := d.Get("virtual_machine_id").(string) // Create a new parameter struct p := cs.NAT.NewEnableStaticNatParams(ipaddressid, virtualmachineid) - if network, ok := d.GetOk("network"); ok { - // Retrieve the network ID - networkid, e := retrieveID(cs, "network", network.(string)) - if e != nil { - return e.Error() - } - - p.SetNetworkid(networkid) + if networkid, ok := d.GetOk("network_id"); ok { + p.SetNetworkid(networkid.(string)) } if vmGuestIP, ok := d.GetOk("vm_guest_ip"); ok { @@ -126,8 +111,8 @@ func resourceCloudStackStaticNATRead(d *schema.ResourceData, meta interface{}) e return nil } - setValueOrID(d, "network", ip.Associatednetworkname, ip.Associatednetworkid) - setValueOrID(d, "virtual_machine", ip.Virtualmachinename, ip.Virtualmachineid) + d.Set("network_id", ip.Associatednetworkid) + d.Set("virtual_machine_id", ip.Virtualmachineid) d.Set("vm_guest_ip", ip.Vmipaddress) return nil diff --git a/builtin/providers/cloudstack/resource_cloudstack_static_nat_test.go b/builtin/providers/cloudstack/resource_cloudstack_static_nat_test.go index f6b86364f46e..be0bd6560b35 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_static_nat_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_static_nat_test.go @@ -66,12 +66,8 @@ func testAccCheckCloudStackStaticNATAttributes( ipaddr *cloudstack.PublicIpAddress) resource.TestCheckFunc { return func(s *terraform.State) error { - if ipaddr.Associatednetworkname != CLOUDSTACK_NETWORK_1 { - return fmt.Errorf("Bad network: %s", ipaddr.Associatednetworkname) - } - - if ipaddr.Virtualmachinename != "terraform-test" { - return fmt.Errorf("Bad virtual_machine: %s", ipaddr.Virtualmachinename) + if ipaddr.Associatednetworkid != CLOUDSTACK_NETWORK_1 { + return fmt.Errorf("Bad network ID: %s", ipaddr.Associatednetworkid) } return nil @@ -104,7 +100,7 @@ resource "cloudstack_instance" "foobar" { name = "terraform-test" display_name = "terraform-test" service_offering= "%s" - network = "%s" + network_id = "%s" template = "%s" zone = "%s" user_data = "foobar\nfoo\nbar" @@ -112,17 +108,16 @@ resource "cloudstack_instance" "foobar" { } resource "cloudstack_ipaddress" "foo" { - network = "%s" + network_id = "${cloudstack_instance.foobar.network_id}" } resource "cloudstack_static_nat" "foo" { - ipaddress = "${cloudstack_ipaddress.foo.id}" - network = "${cloudstack_ipaddress.foo.network}" - virtual_machine = "${cloudstack_instance.foobar.id}" + ip_address_id = "${cloudstack_ipaddress.foo.id}" + network_id = "${cloudstack_ipaddress.foo.network_id}" + virtual_machine_id = "${cloudstack_instance.foobar.id}" }`, CLOUDSTACK_SERVICE_OFFERING_1, CLOUDSTACK_NETWORK_1, CLOUDSTACK_TEMPLATE, CLOUDSTACK_ZONE, - CLOUDSTACK_NETWORK_1, ) diff --git a/builtin/providers/cloudstack/resource_cloudstack_template.go b/builtin/providers/cloudstack/resource_cloudstack_template.go index 04aaca22ede0..10c24fdbb6da 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_template.go +++ b/builtin/providers/cloudstack/resource_cloudstack_template.go @@ -168,14 +168,8 @@ func resourceCloudStackTemplateCreate(d *schema.ResourceData, meta interface{}) } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // Create the new template diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpc.go b/builtin/providers/cloudstack/resource_cloudstack_vpc.go index d99a4042a523..a51b4dd3136e 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpc.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpc.go @@ -106,14 +106,8 @@ func resourceCloudStackVPCCreate(d *schema.ResourceData, meta interface{}) error } // If there is a project supplied, we retrieve and set the project id - if project, ok := d.GetOk("project"); ok { - // Retrieve the project ID - projectid, e := retrieveID(cs, "project", project.(string)) - if e != nil { - return e.Error() - } - // Set the default project ID - p.SetProjectid(projectid) + if err := setProjectid(p, cs, d); err != nil { + return err } // Create the new VPC @@ -163,8 +157,9 @@ func resourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error { p.SetVpcid(d.Id()) p.SetIssourcenat(true) - if _, ok := d.GetOk("project"); ok { - p.SetProjectid(v.Projectid) + // If there is a project supplied, we retrieve and set the project id + if err := setProjectid(p, cs, d); err != nil { + return err } // Get the source NAT IP assigned to the VPC diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection.go index 322f07a2c9d0..98fb27b9da09 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "log" "strings" @@ -16,17 +17,33 @@ func resourceCloudStackVPNConnection() *schema.Resource { Delete: resourceCloudStackVPNConnectionDelete, Schema: map[string]*schema.Schema{ - "customergatewayid": &schema.Schema{ + "customer_gateway_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, - "vpngatewayid": &schema.Schema{ + "customergatewayid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `customer_gateway_id` field instead", + }, + + "vpn_gateway_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + + "vpngatewayid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `vpn_gateway_id` field instead", + }, }, } } @@ -34,10 +51,27 @@ func resourceCloudStackVPNConnection() *schema.Resource { func resourceCloudStackVPNConnectionCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + customergatewayid, ok := d.GetOk("customer_gateway_id") + if !ok { + customergatewayid, ok = d.GetOk("customergatewayid") + } + if !ok { + return errors.New( + "Either `customer_gateway_id` or [deprecated] `customergatewayid` must be provided.") + } + + vpngatewayid, ok := d.GetOk("vpn_gateway_id") + if !ok { + vpngatewayid, ok = d.GetOk("vpngatewayid") + } + if !ok { + return errors.New("Either `vpn_gateway_id` or [deprecated] `vpngatewayid` must be provided.") + } + // Create a new parameter struct p := cs.VPN.NewCreateVpnConnectionParams( - d.Get("customergatewayid").(string), - d.Get("vpngatewayid").(string), + customergatewayid.(string), + vpngatewayid.(string), ) // Create the new VPN Connection @@ -66,8 +100,8 @@ func resourceCloudStackVPNConnectionRead(d *schema.ResourceData, meta interface{ return err } - d.Set("customergatewayid", v.S2scustomergatewayid) - d.Set("vpngatewayid", v.S2svpngatewayid) + d.Set("customer_gateway_id", v.S2scustomergatewayid) + d.Set("vpn_gateway_id", v.S2svpngatewayid) return nil } diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go index 7d09eea9bb5e..930866853901 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go @@ -96,11 +96,11 @@ resource "cloudstack_vpc" "bar" { } resource "cloudstack_vpn_gateway" "foo" { - vpc = "${cloudstack_vpc.foo.name}" + vpc_id = "${cloudstack_vpc.foo.id}" } resource "cloudstack_vpn_gateway" "bar" { - vpc = "${cloudstack_vpc.bar.name}" + vpc_id = "${cloudstack_vpc.bar.id}" } resource "cloudstack_vpn_customer_gateway" "foo" { @@ -122,13 +122,13 @@ resource "cloudstack_vpn_customer_gateway" "bar" { } resource "cloudstack_vpn_connection" "foo-bar" { - customergatewayid = "${cloudstack_vpn_customer_gateway.foo.id}" - vpngatewayid = "${cloudstack_vpn_gateway.bar.id}" + customer_gateway_id = "${cloudstack_vpn_customer_gateway.foo.id}" + vpn_gateway_id = "${cloudstack_vpn_gateway.bar.id}" } resource "cloudstack_vpn_connection" "bar-foo" { - customergatewayid = "${cloudstack_vpn_customer_gateway.bar.id}" - vpngatewayid = "${cloudstack_vpn_gateway.foo.id}" + customer_gateway_id = "${cloudstack_vpn_customer_gateway.bar.id}" + vpn_gateway_id = "${cloudstack_vpn_gateway.foo.id}" }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go index b24eb356721c..acf181ace677 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go @@ -188,11 +188,11 @@ resource "cloudstack_vpc" "bar" { } resource "cloudstack_vpn_gateway" "foo" { - vpc = "${cloudstack_vpc.foo.name}" + vpc_id = "${cloudstack_vpc.foo.id}" } resource "cloudstack_vpn_gateway" "bar" { - vpc = "${cloudstack_vpc.bar.name}" + vpc_id = "${cloudstack_vpc.bar.id}" } resource "cloudstack_vpn_customer_gateway" "foo" { @@ -235,11 +235,11 @@ resource "cloudstack_vpc" "bar" { } resource "cloudstack_vpn_gateway" "foo" { - vpc = "${cloudstack_vpc.foo.name}" + vpc_id = "${cloudstack_vpc.foo.id}" } resource "cloudstack_vpn_gateway" "bar" { - vpc = "${cloudstack_vpc.bar.name}" + vpc_id = "${cloudstack_vpc.bar.id}" } resource "cloudstack_vpn_customer_gateway" "foo" { diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway.go index 17533a3a6250..b6a926dc128e 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway.go @@ -1,6 +1,7 @@ package cloudstack import ( + "errors" "fmt" "log" "strings" @@ -16,12 +17,20 @@ func resourceCloudStackVPNGateway() *schema.Resource { Delete: resourceCloudStackVPNGatewayDelete, Schema: map[string]*schema.Schema{ - "vpc": &schema.Schema{ + "vpc_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, ForceNew: true, }, + "vpc": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "Please use the `vpc_id` field instead", + }, + "public_ip": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -33,8 +42,16 @@ func resourceCloudStackVPNGateway() *schema.Resource { func resourceCloudStackVPNGatewayCreate(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + vpc, ok := d.GetOk("vpc_id") + if !ok { + vpc, ok = d.GetOk("vpc") + } + if !ok { + return errors.New("Either `vpc_id` or [deprecated] `vpc` must be provided.") + } + // Retrieve the VPC ID - vpcid, e := retrieveID(cs, "vpc", d.Get("vpc").(string)) + vpcid, e := retrieveID(cs, "vpc", vpc.(string)) if e != nil { return e.Error() } @@ -45,7 +62,7 @@ func resourceCloudStackVPNGatewayCreate(d *schema.ResourceData, meta interface{} // Create the new VPN Gateway v, err := cs.VPN.CreateVpnGateway(p) if err != nil { - return fmt.Errorf("Error creating VPN Gateway for VPC %s: %s", d.Get("vpc").(string), err) + return fmt.Errorf("Error creating VPN Gateway for VPC ID %s: %s", vpcid, err) } d.SetId(v.Id) @@ -61,7 +78,7 @@ func resourceCloudStackVPNGatewayRead(d *schema.ResourceData, meta interface{}) if err != nil { if count == 0 { log.Printf( - "[DEBUG] VPN Gateway for VPC %s does no longer exist", d.Get("vpc").(string)) + "[DEBUG] VPN Gateway for VPC ID %s does no longer exist", d.Get("vpc_id").(string)) d.SetId("") return nil } @@ -69,8 +86,7 @@ func resourceCloudStackVPNGatewayRead(d *schema.ResourceData, meta interface{}) return err } - setValueOrID(d, "vpc", d.Get("vpc").(string), v.Vpcid) - + d.Set("vpc_id", v.Vpcid) d.Set("public_ip", v.Publicip) return nil @@ -92,7 +108,7 @@ func resourceCloudStackVPNGatewayDelete(d *schema.ResourceData, meta interface{} return nil } - return fmt.Errorf("Error deleting VPN Gateway for VPC %s: %s", d.Get("vpc").(string), err) + return fmt.Errorf("Error deleting VPN Gateway for VPC %s: %s", d.Get("vpc_id").(string), err) } return nil diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway_test.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway_test.go index 61fc151601b9..862daefe97aa 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_gateway_test.go @@ -22,8 +22,6 @@ func TestAccCloudStackVPNGateway_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackVPNGatewayExists( "cloudstack_vpn_gateway.foo", &vpnGateway), - resource.TestCheckResourceAttr( - "cloudstack_vpn_gateway.foo", "vpc", "terraform-vpc"), ), }, }, @@ -90,7 +88,7 @@ resource "cloudstack_vpc" "foo" { } resource "cloudstack_vpn_gateway" "foo" { - vpc = "${cloudstack_vpc.foo.name}" + vpc_id = "${cloudstack_vpc.foo.id}" }`, CLOUDSTACK_VPC_CIDR_1, CLOUDSTACK_VPC_OFFERING, diff --git a/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown b/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown index acec778d9847..4abd541ae73e 100644 --- a/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown +++ b/website/source/docs/providers/cloudstack/r/egress_firewall.html.markdown @@ -14,7 +14,7 @@ Creates egress firewall rules for a given network. ``` resource "cloudstack_egress_firewall" "default" { - network = "test-network" + network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" rule { cidr_list = ["10.0.0.0/8"] @@ -28,8 +28,11 @@ resource "cloudstack_egress_firewall" "default" { The following arguments are supported: -* `network` - (Required) The network for which to create the egress firewall - rules. Changing this forces a new resource to be created. +* `network_id` - (Required) The network ID for which to create the egress + firewall rules. Changing this forces a new resource to be created. + +* `network` - (Required, Deprecated) The network for which to create the egress + firewall rules. Changing this forces a new resource to be created. * `managed` - (Optional) USE WITH CAUTION! If enabled all the egress firewall rules for this network will be managed by this resource. This means it will diff --git a/website/source/docs/providers/cloudstack/r/firewall.html.markdown b/website/source/docs/providers/cloudstack/r/firewall.html.markdown index 4120306f53b5..f5e174aeb23e 100644 --- a/website/source/docs/providers/cloudstack/r/firewall.html.markdown +++ b/website/source/docs/providers/cloudstack/r/firewall.html.markdown @@ -14,7 +14,7 @@ Creates firewall rules for a given IP address. ``` resource "cloudstack_firewall" "default" { - ip_address = "192.168.0.1" + ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" rule { cidr_list = ["10.0.0.0/8"] @@ -28,8 +28,8 @@ resource "cloudstack_firewall" "default" { The following arguments are supported: -* `ip_address` - (Required) The IP address or ID for which to create the firewall - rules. Changing this forces a new resource to be created. +* `ip_address_id` - (Required) The IP address ID for which to create the + firewall rules. Changing this forces a new resource to be created. * `ipaddress` - (Required, Deprecated) The IP address or ID for which to create the firewall rules. Changing this forces a new resource to be created. diff --git a/website/source/docs/providers/cloudstack/r/instance.html.markdown b/website/source/docs/providers/cloudstack/r/instance.html.markdown index 40bbc6d82761..cd3c8b9185bf 100644 --- a/website/source/docs/providers/cloudstack/r/instance.html.markdown +++ b/website/source/docs/providers/cloudstack/r/instance.html.markdown @@ -17,7 +17,7 @@ disk offering, and template. resource "cloudstack_instance" "web" { name = "server-1" service_offering= "small" - network = "network-1" + network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" template = "CentOS 6.5" zone = "zone-1" } @@ -34,9 +34,12 @@ The following arguments are supported: * `service_offering` - (Required) The name or ID of the service offering used for this instance. -* `network` - (Optional) The name or ID of the network to connect this instance +* `network_id` - (Optional) The ID of the network to connect this instance to. Changing this forces a new resource to be created. +* `network` - (Optional, Deprecated) The name or ID of the network to connect + this instance to. Changing this forces a new resource to be created. + * `ip_address` - (Optional) The IP address to assign to this instance. Changing this forces a new resource to be created. diff --git a/website/source/docs/providers/cloudstack/r/ipaddress.html.markdown b/website/source/docs/providers/cloudstack/r/ipaddress.html.markdown index 45315a0f7821..eeed95f9b65c 100644 --- a/website/source/docs/providers/cloudstack/r/ipaddress.html.markdown +++ b/website/source/docs/providers/cloudstack/r/ipaddress.html.markdown @@ -14,7 +14,7 @@ Acquires and associates a public IP. ``` resource "cloudstack_ipaddress" "default" { - network = "test-network" + network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" } ``` @@ -22,16 +22,24 @@ resource "cloudstack_ipaddress" "default" { The following arguments are supported: -* `network` - (Optional) The name or ID of the network for which an IP address should +* `network_id` - (Optional) The ID of the network for which an IP address should be acquired and associated. Changing this forces a new resource to be created. -* `vpc` - (Optional) The name or ID of the VPC for which an IP address should - be acquired and associated. Changing this forces a new resource to be created. +* `network` - (Optional, Deprecated) The name or ID of the network for which an IP + addess should be acquired and associated. Changing this forces a new resource + to be created. + +* `vpc_id` - (Optional) The ID of the VPC for which an IP address should be + acquired and associated. Changing this forces a new resource to be created. + +* `vpc` - (Optional, Deprecated) The name or ID of the VPC for which an IP address + should be acquired and associated. Changing this forces a new resource to be + created. * `project` - (Optional) The name or ID of the project to deploy this instance to. Changing this forces a new resource to be created. -*NOTE: Either `network` or `vpc` should have a value!* +*NOTE: Either `network_id` or `vpc_id` should have a value!* ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/loadbalancer_rule.html.markdown b/website/source/docs/providers/cloudstack/r/loadbalancer_rule.html.markdown index eb374096bc6f..65a252a2d9fb 100644 --- a/website/source/docs/providers/cloudstack/r/loadbalancer_rule.html.markdown +++ b/website/source/docs/providers/cloudstack/r/loadbalancer_rule.html.markdown @@ -16,11 +16,11 @@ Creates a loadbalancer rule. resource "cloudstack_loadbalancer_rule" "default" { name = "loadbalancer-rule-1" description = "Loadbalancer rule 1" - ip_address = "192.168.0.1" + ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" algorithm = "roundrobin" private_port = 80 public_port = 80 - members = ["server-1", "server-2"] + member_ids = ["f8141e2f-4e7e-4c63-9362-986c908b7ea7"] } ``` @@ -33,16 +33,20 @@ The following arguments are supported: * `description` - (Optional) The description of the load balancer rule. -* `ip_address` - (Required) Public ip address from where the network traffic - will be load balanced from. Changing this forces a new resource to be - created. +* `ip_address_id` - (Required) Public IP address ID from where the network + traffic will be load balanced from. Changing this forces a new resource + to be created. -* `ipaddress` - (Required, Deprecated) Public ip address from where the +* `ipaddress` - (Required, Deprecated) Public IP address from where the network traffic will be load balanced from. Changing this forces a new resource to be created. -* `network` - (Optional) The guest network this rule will be created for. - Required when public IP address is not associated with any Guest network +* `network_id` - (Optional) The network ID this rule will be created for. + Required when public IP address is not associated with any network yet + (VPC case). + +* `network` - (Optional, Deprecated) The network this rule will be created + for. Required when public IP address is not associated with any network yet (VPC case). * `algorithm` - (Required) Load balancer rule algorithm (source, roundrobin, @@ -56,8 +60,11 @@ The following arguments are supported: will be load balanced from. Changing this forces a new resource to be created. -* `members` - (Required) List of instances to assign to the load balancer rule. - Changing this forces a new resource to be created. +* `member_ids` - (Required) List of instance IDs to assign to the load balancer + rule. Changing this forces a new resource to be created. + +* `members` - (Required, Deprecated) List of instances to assign to the load + balancer rule. Changing this forces a new resource to be created. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/network.html.markdown b/website/source/docs/providers/cloudstack/r/network.html.markdown index cf7b1ae67bd9..3f00f2ee584f 100644 --- a/website/source/docs/providers/cloudstack/r/network.html.markdown +++ b/website/source/docs/providers/cloudstack/r/network.html.markdown @@ -50,11 +50,17 @@ The following arguments are supported: required by the Network Offering if specifyVlan=true is set. Only the ROOT admin can set this value. -* `vpc` - (Optional) The name or ID of the VPC to create this network for. Changing +* `vpc_id` - (Optional) The ID of the VPC to create this network for. Changing this forces a new resource to be created. -* `aclid` - (Optional) The ID of a network ACL that should be attached to the - network. Changing this forces a new resource to be created. +* `vpc` - (Optional, Deprecated) The name or ID of the VPC to create this network + for. Changing this forces a new resource to be created. + +* `acl_id` - (Optional) The network ACL ID that should be attached to the network. + Changing this forces a new resource to be created. + +* `aclid` - (Optional, Deprecated) The ID of a network ACL that should be attached + to the network. Changing this forces a new resource to be created. * `project` - (Optional) The name or ID of the project to deploy this instance to. Changing this forces a new resource to be created. diff --git a/website/source/docs/providers/cloudstack/r/network_acl.html.markdown b/website/source/docs/providers/cloudstack/r/network_acl.html.markdown index 0001cbffb755..c8d5e433ab79 100644 --- a/website/source/docs/providers/cloudstack/r/network_acl.html.markdown +++ b/website/source/docs/providers/cloudstack/r/network_acl.html.markdown @@ -15,7 +15,7 @@ Creates a Network ACL for the given VPC. ``` resource "cloudstack_network_acl" "default" { name = "test-acl" - vpc = "vpc-1" + vpc_id = "76f6e8dc-07e3-4971-b2a2-8831b0cc4cb4" } ``` @@ -25,10 +25,15 @@ The following arguments are supported: * `name` - (Required) The name of the ACL. Changing this forces a new resource to be created. + * `description` - (Optional) The description of the ACL. Changing this forces a new resource to be created. -* `vpc` - (Required) The name or ID of the VPC to create this ACL for. Changing - this forces a new resource to be created. + +* `vpc_id` - (Required) The ID of the VPC to create this ACL for. Changing this + forces a new resource to be created. + +* `vpc` - (Required, Deprecated) The name or ID of the VPC to create this ACL + for. Changing this forces a new resource to be created. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown b/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown index 267eca346558..4b0ebaa9dfaf 100644 --- a/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown +++ b/website/source/docs/providers/cloudstack/r/network_acl_rule.html.markdown @@ -14,7 +14,7 @@ Creates network ACL rules for a given network ACL. ``` resource "cloudstack_network_acl_rule" "default" { - aclid = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6" + acl_id = "f3843ce0-334c-4586-bbd3-0c2e2bc946c6" rule { action = "allow" @@ -30,9 +30,12 @@ resource "cloudstack_network_acl_rule" "default" { The following arguments are supported: -* `aclid` - (Required) The network ACL ID for which to create the rules. +* `acl_id` - (Required) The network ACL ID for which to create the rules. Changing this forces a new resource to be created. +* `aclid` - (Required, Deprecated) The network ACL ID for which to create + the rules. Changing this forces a new resource to be created. + * `managed` - (Optional) USE WITH CAUTION! If enabled all the firewall rules for this network ACL will be managed by this resource. This means it will delete all firewall rules that are not in your config! (defaults false) diff --git a/website/source/docs/providers/cloudstack/r/nic.html.markdown b/website/source/docs/providers/cloudstack/r/nic.html.markdown index 38aacd87d48c..597b40f6cd60 100644 --- a/website/source/docs/providers/cloudstack/r/nic.html.markdown +++ b/website/source/docs/providers/cloudstack/r/nic.html.markdown @@ -16,9 +16,9 @@ Basic usage: ``` resource "cloudstack_nic" "test" { - network = "network-2" + network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" ip_address = "192.168.1.1" - virtual_machine = "server-1" + virtual_machine_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" } ``` @@ -26,17 +26,24 @@ resource "cloudstack_nic" "test" { The following arguments are supported: -* `network` - (Required) The name or ID of the network to plug the NIC into. Changing +* `network_id` - (Required) The ID of the network to plug the NIC into. Changing this forces a new resource to be created. +* `network` - (Required, Deprecated) The name or ID of the network to plug the + NIC into. Changing this forces a new resource to be created. + * `ip_address` - (Optional) The IP address to assign to the NIC. Changing this forces a new resource to be created. -* `ipaddress` - (Optional, Deprecated) The IP address to assign to the NIC. Changing - this forces a new resource to be created. +* `ipaddress` - (Optional, Deprecated) The IP address to assign to the NIC. + Changing this forces a new resource to be created. + +* `virtual_machine_id` - (Required) The ID of the virtual machine to which to + attach the NIC. Changing this forces a new resource to be created. -* `virtual_machine` - (Required) The name or ID of the virtual machine to which - to attach the NIC. Changing this forces a new resource to be created. +* `virtual_machine` - (Required, Deprecated) The name or ID of the virtual + machine to which to attach the NIC. Changing this forces a new resource to + be created. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/port_forward.html.markdown b/website/source/docs/providers/cloudstack/r/port_forward.html.markdown index 41e3b0b39f72..19e7d4ab6de5 100644 --- a/website/source/docs/providers/cloudstack/r/port_forward.html.markdown +++ b/website/source/docs/providers/cloudstack/r/port_forward.html.markdown @@ -14,13 +14,13 @@ Creates port forwards. ``` resource "cloudstack_port_forward" "default" { - ip_address = "192.168.0.1" + ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" forward { protocol = "tcp" private_port = 80 public_port = 8080 - virtual_machine = "server-1" + virtual_machine_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" } } ``` @@ -29,8 +29,8 @@ resource "cloudstack_port_forward" "default" { The following arguments are supported: -* `ip_address` - (Required) The IP address for which to create the port forwards. - Changing this forces a new resource to be created. +* `ip_address_id` - (Required) The IP address ID for which to create the port + forwards. Changing this forces a new resource to be created. * `ipaddress` - (Required, Deprecated) The IP address for which to create the port forwards. Changing this forces a new resource to be created. @@ -51,7 +51,10 @@ The `forward` block supports: * `public_port` - (Required) The public port to forward from. -* `virtual_machine` - (Required) The name or ID of the virtual machine to forward to. +* `virtual_machine_id` - (Required) The ID of the virtual machine to forward to. + +* `virtual_machine` - (Required, Deprecated) The name or ID of the virtual + machine to forward to. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/secondary_ipaddress.html.markdown b/website/source/docs/providers/cloudstack/r/secondary_ipaddress.html.markdown index 6907796f5603..85d27b01c323 100644 --- a/website/source/docs/providers/cloudstack/r/secondary_ipaddress.html.markdown +++ b/website/source/docs/providers/cloudstack/r/secondary_ipaddress.html.markdown @@ -14,7 +14,7 @@ Assigns a secondary IP to a NIC. ``` resource "cloudstack_secondary_ipaddress" "default" { - virtual_machine = "server-1" + virtual_machine_id = "server-1" } ``` @@ -23,20 +23,28 @@ resource "cloudstack_secondary_ipaddress" "default" { The following arguments are supported: * `ip_address` - (Optional) The IP address to attach the to NIC. If not supplied - an IP address will be selected randomly. Changing this forces a new resource - to be created. + an IP address will be selected randomly. Changing this forces a new resource + to be created. * `ipaddress` - (Optional, Deprecated) The IP address to attach the to NIC. If not supplied an IP address will be selected randomly. Changing this forces a new resource to be created. -* `nicid` - (Optional) The ID of the NIC to which you want to attach the - secondary IP address. Changing this forces a new resource to be - created (defaults to the ID of the primary NIC) +* `nic_id` - (Optional) The NIC ID to which you want to attach the secondary IP + address. Changing this forces a new resource to be created (defaults to the + ID of the primary NIC) -* `virtual_machine` - (Required) The name or ID of the virtual machine to which - you want to attach the secondary IP address. Changing this forces a new - resource to be created. +* `nicid` - (Optional, Deprecated) The ID of the NIC to which you want to attach + the secondary IP address. Changing this forces a new resource to be created + (defaults to the ID of the primary NIC) + +* `virtual_machine_id` - (Required) The ID of the virtual machine to which you + want to attach the secondary IP address. Changing this forces a new resource + to be created. + +* `virtual_machine` - (Required, Deprecated) The name or ID of the virtual + machine to which you want to attach the secondary IP address. Changing this + forces a new resource to be created. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/static_nat.html.markdown b/website/source/docs/providers/cloudstack/r/static_nat.html.markdown index f899309a092c..2f7caf1ab5c3 100644 --- a/website/source/docs/providers/cloudstack/r/static_nat.html.markdown +++ b/website/source/docs/providers/cloudstack/r/static_nat.html.markdown @@ -14,8 +14,8 @@ Enables static NAT for a given IP address ``` resource "cloudstack_static_nat" "default" { - ipaddress = "192.168.0.1" - virtual_machine = "server-1" + ip_address_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" + virtual_machine_id = "6ca2a163-bc68-429c-adc8-ab4a620b1bb3" } ``` @@ -23,18 +23,16 @@ resource "cloudstack_static_nat" "default" { The following arguments are supported: -* `ipaddress` - (Required) The name or ID of the public IP address for which - static NAT will be enabled. Changing this forces a new resource to be - created. +* `ip_address_id` - (Required) The public IP address ID for which static + NAT will be enabled. Changing this forces a new resource to be created. -* `network` - (Optional) The name or ID of the network of the VM the static - NAT will be enabled for. Required when public IP address is not - associated with any guest network yet (VPC case). Changing this forces - a new resource to be created. +* `network_id` - (Optional) The network ID of the VM the static NAT will be + enabled for. Required when public IP address is not associated with any + guest network yet (VPC case). Changing this forces a new resource to be + created. -* `virtual_machine` - (Required) The name or ID of the virtual machine to - enable the static NAT feature for. Changing this forces a new resource - to be created. +* `virtual_machine_id` - (Required) The virtual machine ID to enable the + static NAT feature for. Changing this forces a new resource to be created. * `vm_guest_ip` - (Optional) The virtual machine IP address for the port forwarding rule (useful when the virtual machine has a secondairy NIC). diff --git a/website/source/docs/providers/cloudstack/r/template.html.markdown b/website/source/docs/providers/cloudstack/r/template.html.markdown index b31c24db026e..99525395d05a 100644 --- a/website/source/docs/providers/cloudstack/r/template.html.markdown +++ b/website/source/docs/providers/cloudstack/r/template.html.markdown @@ -31,8 +31,8 @@ The following arguments are supported: * `display_text` - (Optional) The display name of the template. -* `format` - (Required) The format of the template. Valid values are "QCOW2", - "RAW", and "VHD". +* `format` - (Required) The format of the template. Valid values are `QCOW2`, + `RAW`, and `VHD`. * `hypervisor` - (Required) The target hypervisor for the template. Changing this forces a new resource to be created. @@ -43,11 +43,14 @@ The following arguments are supported: * `url` - (Required) The URL of where the template is hosted. Changing this forces a new resource to be created. +* `project` - (Optional) The name or ID of the project to create this template for. + Changing this forces a new resource to be created. + * `zone` - (Required) The name or ID of the zone where this template will be created. Changing this forces a new resource to be created. * `is_dynamically_scalable` - (Optional) Set to indicate if the template contains - tools to support dynamic scaling of VM cpu/memory. + tools to support dynamic scaling of VM cpu/memory (defaults false) * `is_extractable` - (Optional) Set to indicate if the template is extractable (defaults false) diff --git a/website/source/docs/providers/cloudstack/r/vpn_connection.html.markdown b/website/source/docs/providers/cloudstack/r/vpn_connection.html.markdown index 3ecf17cbca65..355fcdb086c8 100644 --- a/website/source/docs/providers/cloudstack/r/vpn_connection.html.markdown +++ b/website/source/docs/providers/cloudstack/r/vpn_connection.html.markdown @@ -16,8 +16,8 @@ Basic usage: ``` resource "cloudstack_vpn_connection" "default" { - customergatewayid = "xxx" - vpngatewayid = "xxx" + customer_gateway_id = "8dab9381-ae73-48b8-9a3d-c460933ef5f7" + vpn_gateway_id = "a7900060-f8a8-44eb-be15-ea54cf499703" } ``` @@ -25,10 +25,16 @@ resource "cloudstack_vpn_connection" "default" { The following arguments are supported: -* `customergatewayid` - (Required) The Customer Gateway ID to connect. +* `customer_gateway_id` - (Required) The Customer Gateway ID to connect. Changing this forces a new resource to be created. -* `vpngatewayid` - (Required) The VPN Gateway ID to connect. +* `customergatewayid` - (Required, Deprecated) The Customer Gateway ID + to connect. Changing this forces a new resource to be created. + +* `vpn_gateway_id` - (Required) The VPN Gateway ID to connect. Changing + this forces a new resource to be created. + +* `vpngatewayid` - (Required, Deprecated) The VPN Gateway ID to connect. Changing this forces a new resource to be created. ## Attributes Reference diff --git a/website/source/docs/providers/cloudstack/r/vpn_gateway.html.markdown b/website/source/docs/providers/cloudstack/r/vpn_gateway.html.markdown index 5bf9cf389cc4..1c74bf1a14d7 100644 --- a/website/source/docs/providers/cloudstack/r/vpn_gateway.html.markdown +++ b/website/source/docs/providers/cloudstack/r/vpn_gateway.html.markdown @@ -16,7 +16,7 @@ Basic usage: ``` resource "cloudstack_vpn_gateway" "default" { - vpc = "test-vpc" + vpc_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" } ``` @@ -24,9 +24,12 @@ resource "cloudstack_vpn_gateway" "default" { The following arguments are supported: -* `vpc` - (Required) The name or ID of the VPC for which to create the VPN Gateway. +* `vpc_id` - (Required) The ID of the VPC for which to create the VPN Gateway. Changing this forces a new resource to be created. +* `vpc` - (Required, Deprecated) The name or ID of the VPC for which to create + the VPN Gateway. Changing this forces a new resource to be created. + ## Attributes Reference The following attributes are exported: From cc298b3fbcee3f1341f8b95a46f1eb7399a0a12c Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 11 Apr 2016 11:33:06 -0400 Subject: [PATCH 057/665] Add issue_template (#6017) --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .github/ISSUE_TEMPLATE.md | 53 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000000..0a0fd39d05f5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,53 @@ +Hi there, + +Thank you for opening an issue. Please note that we try to keep the Terraform +issue tracker reserved for bug reports and feature requests. For general usage +questions, please see: https://www.terraform.io/community.html. + +### Terraform Version +Run `terraform -v` to show the version. If you are not running the latest +version of Terraform, please upgrade because your issue may have already been +fixed. + +### Affected Resource(s) +Please list the resources as a list, for example: +- aws_instance +- dnsimple_record + +If this issue appears to affect multiple resources, it may be an issue with +Terraform's core, so please mention this. + +### Terraform Configuration Files +```hcl +# Copy-paste your Terraform configurations here - for large Terraform configs, +# please use a service like Dropbox and share a link to the ZIP file. For +# security, you can also encrypt the files using our GPG public key. +``` + +### Debug Output +Please provider a link to a GitHub Gist containing the complete debug output: +https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the +debug output in the issue; just paste a link to the Gist. + +### Panic Output +If Terraform produced a panic, please provide a link to a GitHub Gist containing +the output of the `crash.log`. + +### Expected Behavior +What should have happened? + +### Actual Behavior +What actually happened? + +### Steps to Reproduce +Please list the steps requires to reproduce the issue, for example: +1. `terraform apply` + +### Important Factoids +Are there anything atypical about your accounts that we should know? For +example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs? + +### References +Are there any other GitHub issues (open or closed) or Pull Requests that should +be linked here? For example: +- GH-1234 From 0b528054273405897287ee50d8e1b504727e7573 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 11 Apr 2016 10:47:54 -0500 Subject: [PATCH 058/665] Unwrap text in issue template This plays more nicely with mobile email clients. --- .github/ISSUE_TEMPLATE.md | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 0a0fd39d05f5..261adedaa40b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,21 +1,16 @@ Hi there, -Thank you for opening an issue. Please note that we try to keep the Terraform -issue tracker reserved for bug reports and feature requests. For general usage -questions, please see: https://www.terraform.io/community.html. +Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html. ### Terraform Version -Run `terraform -v` to show the version. If you are not running the latest -version of Terraform, please upgrade because your issue may have already been -fixed. +Run `terraform -v` to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed. ### Affected Resource(s) Please list the resources as a list, for example: - aws_instance - dnsimple_record -If this issue appears to affect multiple resources, it may be an issue with -Terraform's core, so please mention this. +If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this. ### Terraform Configuration Files ```hcl @@ -25,13 +20,10 @@ Terraform's core, so please mention this. ``` ### Debug Output -Please provider a link to a GitHub Gist containing the complete debug output: -https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the -debug output in the issue; just paste a link to the Gist. +Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist. ### Panic Output -If Terraform produced a panic, please provide a link to a GitHub Gist containing -the output of the `crash.log`. +If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the `crash.log`. ### Expected Behavior What should have happened? @@ -44,10 +36,8 @@ Please list the steps requires to reproduce the issue, for example: 1. `terraform apply` ### Important Factoids -Are there anything atypical about your accounts that we should know? For -example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs? +Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs? ### References -Are there any other GitHub issues (open or closed) or Pull Requests that should -be linked here? For example: +Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example: - GH-1234 From e9a918f83d28fb7835fc4835300dfbdb23c34814 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 11 Apr 2016 11:53:02 -0400 Subject: [PATCH 059/665] Update CHANGELOG --- CHANGELOG.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6ec1e6d0135..47d640911183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ IMPROVEMENTS: * provider/datadog: Add heredoc support to message, escalation_message, and query [GH-5788] * provider/docker: Add support for docker run --user option [GH-5300] * provider/google: Accept GOOGLE_CLOUD_KEYFILE_JSON env var for credentials [GH-6007] + * provider/google: Make "project" attribute on provider configuration optional [GH-6112] + * provider/google: Add "project" argument and attribute to all GCP compute resources which inherit from the provider's value [GH-6112] + *provider/google: Deprecate unused "region" attribute in `global_forwarding_rule`; this attribute was never used anywhere in the computation of the resource [GH-6112] * provider/github: Add support for privacy to `github_team` [GH-6116] * provider/cloudstack: Deprecate `ipaddress` in favour of `ip_address` in all resources [GH-6010] * provider/openstack: Allow subnets with no gateway [GH-6060] @@ -265,7 +268,7 @@ BUG FIXES: * provider/google: Fix reading of `google_compute_vpn_gateway` without an explicit ([#5125](https://github.com/hashicorp/terraform/issues/5125)) * provider/google: Fix crash when setting `ack_deadline_seconds` on `google_pubsub_subscription` ([#5110](https://github.com/hashicorp/terraform/issues/5110)) * provider/openstack: Fix crash when `access_network` was not defined in instances ([#4966](https://github.com/hashicorp/terraform/issues/4966)) - * provider/powerdns: Fix refresh of `powerdns_record` no longer fails if the record name contains a `-` ([#5228](https://github.com/hashicorp/terraform/issues/5228)) + * provider/powerdns: Fix refresh of `powerdns_record` no longer fails if the record name contains a `-` ([#5228](https://github.com/hashicorp/terraform/issues/5228)) * provider/vcd: Wait for DHCP assignment when creating `vcd_vapp` resources with no static IP assignment ([#5195](https://github.com/hashicorp/terraform/issues/5195)) ## 0.6.11 (February 1, 2016) @@ -286,8 +289,8 @@ IMPROVEMENTS: * provider/template: Remove unnecessary mime-type validation from `template_cloudinit_config` resources ([#4873](https://github.com/hashicorp/terraform/issues/4873)) * provider/template: Correct spelling of "Boundary" in the part separator of rendered `template_cloudinit_config` resources ([#4873](https://github.com/hashicorp/terraform/issues/4873)) * provider/aws: Provide a better message if no AWS creds are found ([#4869](https://github.com/hashicorp/terraform/issues/4869)) - * provider/openstack: Ability to specify per-network Floating IPs ([#4812](https://github.com/hashicorp/terraform/issues/4812)) - + * provider/openstack: Ability to specify per-network Floating IPs ([#4812](https://github.com/hashicorp/terraform/issues/4812)) + BUG FIXES: * provider/aws: `aws_autoscale_schedule` 0 values ([#4693](https://github.com/hashicorp/terraform/issues/4693)) @@ -298,7 +301,7 @@ BUG FIXES: * provider/azurerm: Fix panic if no creds supplied ([#4902](https://github.com/hashicorp/terraform/issues/4902)) * provider/openstack: Changing the port resource to mark the ip_address as optional ([#4850](https://github.com/hashicorp/terraform/issues/4850)) * provider/docker: Catch potential custom network errors in docker ([#4918](https://github.com/hashicorp/terraform/issues/4918)) - + ## 0.6.10 (January 27, 2016) @@ -354,7 +357,7 @@ IMPROVEMENTS: * provider/aws: Enable specifying aws s3 redirect protocol ([#4098](https://github.com/hashicorp/terraform/issues/4098)) * provider/aws: Added support for `encrypted` on `ebs_block_devices` in Launch Configurations ([#4481](https://github.com/hashicorp/terraform/issues/4481)) * provider/aws: Retry Listener Creation for ELBs ([#4825](https://github.com/hashicorp/terraform/issues/4825)) - * provider/aws: Add support for creating Managed Microsoft Active Directory + * provider/aws: Add support for creating Managed Microsoft Active Directory and Directory Connectors ([#4388](https://github.com/hashicorp/terraform/issues/4388)) * provider/aws: Mark some `aws_db_instance` fields as optional ([#3138](https://github.com/hashicorp/terraform/issues/3138)) * provider/digitalocean: Add support for reassigning `digitalocean_floating_ip` resources ([#4476](https://github.com/hashicorp/terraform/issues/4476)) From 337895b51e2d11a04324adb708e02fe0bd394c03 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 10 Apr 2016 19:31:40 -0400 Subject: [PATCH 060/665] Read more default envvars for GCP - Closes #5874 - Fixes #5872 --- builtin/providers/google/provider.go | 21 ++++++++--- builtin/providers/google/provider_test.go | 37 +++++++++++++++---- .../docs/providers/google/index.html.markdown | 27 ++++++++++---- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/builtin/providers/google/provider.go b/builtin/providers/google/provider.go index 8fd5339f51b3..89e176979a62 100644 --- a/builtin/providers/google/provider.go +++ b/builtin/providers/google/provider.go @@ -27,20 +27,29 @@ func Provider() terraform.ResourceProvider { DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CREDENTIALS", "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON", }, nil), ValidateFunc: validateCredentials, }, "project": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("GOOGLE_PROJECT", ""), + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "GOOGLE_PROJECT", + "GCLOUD_PROJECT", + "CLOUDSDK_CORE_PROJECT", + }, nil), }, "region": &schema.Schema{ - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("GOOGLE_REGION", nil), + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "GOOGLE_REGION", + "GCLOUD_REGION", + "CLOUDSDK_COMPUTE_REGION", + }, nil), }, }, diff --git a/builtin/providers/google/provider_test.go b/builtin/providers/google/provider_test.go index 9bf5414b74e4..40bf1654efaa 100644 --- a/builtin/providers/google/provider_test.go +++ b/builtin/providers/google/provider_test.go @@ -3,6 +3,7 @@ package google import ( "io/ioutil" "os" + "strings" "testing" "github.com/hashicorp/terraform/helper/schema" @@ -38,18 +39,40 @@ func testAccPreCheck(t *testing.T) { os.Setenv("GOOGLE_CREDENTIALS", string(creds)) } - if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" { - if w := os.Getenv("GOOGLE_CLOUD_KEYFILE_JSON"); w == "" { - t.Fatal("GOOGLE_CREDENTIALS or GOOGLE_CLOUD_KEYFILE_JSON must be set for acceptance tests") + multiEnvSearch := func(ks []string) string { + for _, k := range ks { + if v := os.Getenv(k); v != "" { + return v + } } + return "" } - if v := os.Getenv("GOOGLE_PROJECT"); v == "" { - t.Fatal("GOOGLE_PROJECT must be set for acceptance tests") + creds := []string{ + "GOOGLE_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON", + } + if v := multiEnvSearch(creds); v == "" { + t.Fatalf("One of %s must be set for acceptance tests", strings.Join(creds, ", ")) } - if v := os.Getenv("GOOGLE_REGION"); v != "us-central1" { - t.Fatal("GOOGLE_REGION must be set to us-central1 for acceptance tests") + projs := []string{ + "GOOGLE_PROJECT", + "GCLOUD_PROJECT", + "CLOUDSDK_CORE_PROJECT", + } + if v := multiEnvSearch(projs); v == "" { + t.Fatalf("One of %s must be set for acceptance tests", strings.Join(creds, ", ")) + } + + regs := []string{ + "GOOGLE_REGION", + "GCLOUD_REGION", + "CLOUDSDK_COMPUTE_REGION", + } + if v := multiEnvSearch(regs); v != "us-central-1" { + t.Fatalf("One of %s must be set to us-central-1 for acceptance tests", strings.Join(creds, ", ")) } } diff --git a/website/source/docs/providers/google/index.html.markdown b/website/source/docs/providers/google/index.html.markdown index 641e2b419093..936cc26121b4 100644 --- a/website/source/docs/providers/google/index.html.markdown +++ b/website/source/docs/providers/google/index.html.markdown @@ -39,17 +39,28 @@ The following keys can be used to configure the provider. retrieving this file are below. Credentials may be blank if you are running Terraform from a GCE instance with a properly-configured [Compute Engine Service Account](https://cloud.google.com/compute/docs/authentication). This - can also be specified with the `GOOGLE_CREDENTIALS` or `GOOGLE_CLOUD_KEYFILE_JSON` - shell environment variable, containing the contents of the credentials file. + can also be specified using any of the following environment variables + (listed in order of precedence): + + * `GOOGLE_CREDENTIALS` + * `GOOGLE_CLOUD_KEYFILE_JSON` + * `GCLOUD_KEYFILE_JSON` + +* `project` - (Required) The ID of the project to apply any resources to. This + can be specified using any of the following environment variables (listed in + order of precedence): + + * `GOOGLE_PROJECT` + * `GCLOUD_PROJECT` + * `CLOUDSDK_CORE_PROJECT` * `region` - (Required) The region to operate under. This can also be specified - with the `GOOGLE_REGION` shell environment variable. + using any of the following environment variables (listed in order of + precedence): -* `project` - (Optional) The ID of the project to apply resources in. This - can also be specified with the `GOOGLE_PROJECT` shell environment variable. - If unspecified, users will need to specify the `project` attribute for - all resources. If specified, resources which do not depend on a project will - ignore this value. + * `GOOGLE_REGION` + * `GCLOUD_REGION` + * `CLOUDSDK_COMPUTE_REGION` The following keys are supported for backwards compatibility, and may be removed in a future version: From 2ea8c64079e7d166adb5b8d91eb802fdec510d27 Mon Sep 17 00:00:00 2001 From: Clint Date: Mon, 11 Apr 2016 12:06:28 -0500 Subject: [PATCH 061/665] provider/aws: More randomization to our Acc tests (#6124) * provider/aws: Add more Randomization to DB Parameter Group Tests, to avoid collisions * provider/aws: Add more randomization to Autoscaling group tests --- .../resource_aws_autoscaling_group_test.go | 59 +++++++++++-------- .../resource_aws_db_parameter_group_test.go | 41 +++++++------ 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index ec29cda490ba..c41b3dc6e88c 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/autoscaling" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -18,21 +19,23 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { var group autoscaling.Group var lc autoscaling.LaunchConfiguration + randName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10)) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSAutoScalingGroupConfig, + Config: testAccAWSAutoScalingGroupConfig(randName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAWSAutoScalingGroupHealthyCapacity(&group, 2), - testAccCheckAWSAutoScalingGroupAttributes(&group), + testAccCheckAWSAutoScalingGroupAttributes(&group, randName), resource.TestCheckResourceAttr( "aws_autoscaling_group.bar", "availability_zones.2487133097", "us-west-2a"), resource.TestCheckResourceAttr( - "aws_autoscaling_group.bar", "name", "foobar3-terraform-test"), + "aws_autoscaling_group.bar", "name", randName), resource.TestCheckResourceAttr( "aws_autoscaling_group.bar", "max_size", "5"), resource.TestCheckResourceAttr( @@ -53,7 +56,7 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { }, resource.TestStep{ - Config: testAccAWSAutoScalingGroupConfigUpdate, + Config: testAccAWSAutoScalingGroupConfigUpdate(randName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAWSLaunchConfigurationExists("aws_launch_configuration.new", &lc), @@ -139,13 +142,15 @@ func TestAccAWSAutoScalingGroup_terminationPolicies(t *testing.T) { func TestAccAWSAutoScalingGroup_tags(t *testing.T) { var group autoscaling.Group + randName := fmt.Sprintf("tfautotags-%s", acctest.RandString(5)) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSAutoScalingGroupConfig, + Config: testAccAWSAutoScalingGroupConfig(randName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAutoscalingTags(&group.Tags, "Foo", map[string]interface{}{ @@ -156,7 +161,7 @@ func TestAccAWSAutoScalingGroup_tags(t *testing.T) { }, resource.TestStep{ - Config: testAccAWSAutoScalingGroupConfigUpdate, + Config: testAccAWSAutoScalingGroupConfigUpdate(randName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAutoscalingTagNotExists(&group.Tags, "Foo"), @@ -217,7 +222,7 @@ func TestAccAWSAutoScalingGroup_WithLoadBalancer(t *testing.T) { CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: fmt.Sprintf(testAccAWSAutoScalingGroupConfigWithLoadBalancer), + Config: testAccAWSAutoScalingGroupConfigWithLoadBalancer, Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), testAccCheckAWSAutoScalingGroupAttributesLoadBalancer(&group), @@ -230,17 +235,18 @@ func TestAccAWSAutoScalingGroup_WithLoadBalancer(t *testing.T) { func TestAccAWSAutoScalingGroup_withPlacementGroup(t *testing.T) { var group autoscaling.Group + randName := fmt.Sprintf("tf_placement_test-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSAutoScalingGroupConfig_withPlacementGroup, + Config: testAccAWSAutoScalingGroupConfig_withPlacementGroup(randName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), resource.TestCheckResourceAttr( - "aws_autoscaling_group.bar", "placement_group", "tf_placement_test"), + "aws_autoscaling_group.bar", "placement_group", randName), ), }, }, @@ -310,14 +316,14 @@ func testAccCheckAWSAutoScalingGroupDestroy(s *terraform.State) error { return nil } -func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.Group) resource.TestCheckFunc { +func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.Group, name string) resource.TestCheckFunc { return func(s *terraform.State) error { if *group.AvailabilityZones[0] != "us-west-2a" { return fmt.Errorf("Bad availability_zones: %#v", group.AvailabilityZones[0]) } - if *group.AutoScalingGroupName != "foobar3-terraform-test" { - return fmt.Errorf("Bad name: %s", *group.AutoScalingGroupName) + if *group.AutoScalingGroupName != name { + return fmt.Errorf("Bad Autoscaling Group name, expected (%s), got (%s)", name, *group.AutoScalingGroupName) } if *group.MaxSize != 5 { @@ -539,20 +545,21 @@ resource "aws_autoscaling_group" "bar" { } ` -const testAccAWSAutoScalingGroupConfig = ` +func testAccAWSAutoScalingGroupConfig(name string) string { + return fmt.Sprintf(` resource "aws_launch_configuration" "foobar" { image_id = "ami-21f78e11" instance_type = "t1.micro" } resource "aws_placement_group" "test" { - name = "test" + name = "%s" strategy = "cluster" } resource "aws_autoscaling_group" "bar" { availability_zones = ["us-west-2a"] - name = "foobar3-terraform-test" + name = "%s" max_size = 5 min_size = 2 health_check_type = "ELB" @@ -568,9 +575,11 @@ resource "aws_autoscaling_group" "bar" { propagate_at_launch = true } } -` +`, name, name) +} -const testAccAWSAutoScalingGroupConfigUpdate = ` +func testAccAWSAutoScalingGroupConfigUpdate(name string) string { + return fmt.Sprintf(` resource "aws_launch_configuration" "foobar" { image_id = "ami-21f78e11" instance_type = "t1.micro" @@ -583,7 +592,7 @@ resource "aws_launch_configuration" "new" { resource "aws_autoscaling_group" "bar" { availability_zones = ["us-west-2a"] - name = "foobar3-terraform-test" + name = "%s" max_size = 5 min_size = 2 health_check_grace_period = 300 @@ -600,7 +609,8 @@ resource "aws_autoscaling_group" "bar" { propagate_at_launch = true } } -` +`, name) +} const testAccAWSAutoScalingGroupConfigWithLoadBalancer = ` resource "aws_vpc" "foo" { @@ -668,7 +678,6 @@ resource "aws_launch_configuration" "foobar" { resource "aws_autoscaling_group" "bar" { availability_zones = ["${aws_subnet.foo.availability_zone}"] vpc_zone_identifier = ["${aws_subnet.foo.id}"] - name = "foobar3-terraform-test" max_size = 2 min_size = 2 health_check_grace_period = 300 @@ -747,20 +756,21 @@ resource "aws_autoscaling_group" "bar" { } ` -const testAccAWSAutoScalingGroupConfig_withPlacementGroup = ` +func testAccAWSAutoScalingGroupConfig_withPlacementGroup(name string) string { + return fmt.Sprintf(` resource "aws_launch_configuration" "foobar" { image_id = "ami-21f78e11" instance_type = "c3.large" } resource "aws_placement_group" "test" { - name = "tf_placement_test" + name = "%s" strategy = "cluster" } resource "aws_autoscaling_group" "bar" { availability_zones = ["us-west-2a"] - name = "foobar3-terraform-test" + name = "%s" max_size = 1 min_size = 1 health_check_grace_period = 300 @@ -778,7 +788,8 @@ resource "aws_autoscaling_group" "bar" { propagate_at_launch = true } } -` +`, name, name) +} const testAccAWSAutoscalingMetricsCollectionConfig_allMetricsCollected = ` resource "aws_launch_configuration" "foobar" { diff --git a/builtin/providers/aws/resource_aws_db_parameter_group_test.go b/builtin/providers/aws/resource_aws_db_parameter_group_test.go index d4b24204b8c4..e076b02aeb5c 100644 --- a/builtin/providers/aws/resource_aws_db_parameter_group_test.go +++ b/builtin/providers/aws/resource_aws_db_parameter_group_test.go @@ -17,18 +17,20 @@ import ( func TestAccAWSDBParameterGroup_basic(t *testing.T) { var v rds.DBParameterGroup + groupName := fmt.Sprintf("parameter-group-test-terraform-%d", acctest.RandInt()) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSDBParameterGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSDBParameterGroupConfig(acctest.RandInt()), + Config: testAccAWSDBParameterGroupConfig(groupName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSDBParameterGroupExists("aws_db_parameter_group.bar", &v), - testAccCheckAWSDBParameterGroupAttributes(&v), + testAccCheckAWSDBParameterGroupAttributes(&v, groupName), resource.TestCheckResourceAttr( - "aws_db_parameter_group.bar", "name", "parameter-group-test-terraform"), + "aws_db_parameter_group.bar", "name", groupName), resource.TestCheckResourceAttr( "aws_db_parameter_group.bar", "family", "mysql5.6"), resource.TestCheckResourceAttr( @@ -50,12 +52,12 @@ func TestAccAWSDBParameterGroup_basic(t *testing.T) { ), }, resource.TestStep{ - Config: testAccAWSDBParameterGroupAddParametersConfig(acctest.RandInt()), + Config: testAccAWSDBParameterGroupAddParametersConfig(groupName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSDBParameterGroupExists("aws_db_parameter_group.bar", &v), - testAccCheckAWSDBParameterGroupAttributes(&v), + testAccCheckAWSDBParameterGroupAttributes(&v, groupName), resource.TestCheckResourceAttr( - "aws_db_parameter_group.bar", "name", "parameter-group-test-terraform"), + "aws_db_parameter_group.bar", "name", groupName), resource.TestCheckResourceAttr( "aws_db_parameter_group.bar", "family", "mysql5.6"), resource.TestCheckResourceAttr( @@ -88,21 +90,22 @@ func TestAccAWSDBParameterGroup_basic(t *testing.T) { }) } -func TestAccAWSDBParameterGroupOnly(t *testing.T) { +func TestAccAWSDBParameterGroup_Only(t *testing.T) { var v rds.DBParameterGroup + groupName := fmt.Sprintf("parameter-group-test-terraform-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSDBParameterGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSDBParameterGroupOnlyConfig(acctest.RandInt()), + Config: testAccAWSDBParameterGroupOnlyConfig(groupName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSDBParameterGroupExists("aws_db_parameter_group.bar", &v), - testAccCheckAWSDBParameterGroupAttributes(&v), + testAccCheckAWSDBParameterGroupAttributes(&v, groupName), resource.TestCheckResourceAttr( - "aws_db_parameter_group.bar", "name", "parameter-group-test-terraform"), + "aws_db_parameter_group.bar", "name", groupName), resource.TestCheckResourceAttr( "aws_db_parameter_group.bar", "family", "mysql5.6"), resource.TestCheckResourceAttr( @@ -187,11 +190,11 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error { return nil } -func testAccCheckAWSDBParameterGroupAttributes(v *rds.DBParameterGroup) resource.TestCheckFunc { +func testAccCheckAWSDBParameterGroupAttributes(v *rds.DBParameterGroup, name string) resource.TestCheckFunc { return func(s *terraform.State) error { - if *v.DBParameterGroupName != "parameter-group-test-terraform" { - return fmt.Errorf("bad name: %#v", v.DBParameterGroupName) + if *v.DBParameterGroupName != name { + return fmt.Errorf("Bad Parameter Group name, expected (%s), got (%s)", name, *v.DBParameterGroupName) } if *v.DBParameterGroupFamily != "mysql5.6" { @@ -250,10 +253,10 @@ func randomString(strlen int) string { return string(result) } -func testAccAWSDBParameterGroupConfig(n int) string { +func testAccAWSDBParameterGroupConfig(n string) string { return fmt.Sprintf(` resource "aws_db_parameter_group" "bar" { - name = "parameter-group-test-terraform-%d" + name = "%s" family = "mysql5.6" description = "Test parameter group for terraform" parameter { @@ -274,10 +277,10 @@ resource "aws_db_parameter_group" "bar" { }`, n) } -func testAccAWSDBParameterGroupAddParametersConfig(n int) string { +func testAccAWSDBParameterGroupAddParametersConfig(n string) string { return fmt.Sprintf(` resource "aws_db_parameter_group" "bar" { - name = "parameter-group-test-terraform-%d" + name = "%s" family = "mysql5.6" description = "Test parameter group for terraform" parameter { @@ -307,10 +310,10 @@ resource "aws_db_parameter_group" "bar" { }`, n) } -func testAccAWSDBParameterGroupOnlyConfig(n int) string { +func testAccAWSDBParameterGroupOnlyConfig(n string) string { return fmt.Sprintf(` resource "aws_db_parameter_group" "bar" { - name = "parameter-group-test-terraform-%d" + name = "%s" family = "mysql5.6" description = "Test parameter group for terraform" }`, n) From 3a2c40d02705b630380539d7b215f3231876514b Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 11 Apr 2016 13:18:56 -0400 Subject: [PATCH 062/665] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d640911183..130c357278c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ IMPROVEMENTS: * provider/google: Make "project" attribute on provider configuration optional [GH-6112] * provider/google: Add "project" argument and attribute to all GCP compute resources which inherit from the provider's value [GH-6112] *provider/google: Deprecate unused "region" attribute in `global_forwarding_rule`; this attribute was never used anywhere in the computation of the resource [GH-6112] + * provider/google: Read more common configuration values from the environment and clarify precedence ordering [GH-6114] * provider/github: Add support for privacy to `github_team` [GH-6116] * provider/cloudstack: Deprecate `ipaddress` in favour of `ip_address` in all resources [GH-6010] * provider/openstack: Allow subnets with no gateway [GH-6060] From fc9825e4c4ca003e0419bdc8b72dd753aa0c7a59 Mon Sep 17 00:00:00 2001 From: Xavier Sellier Date: Mon, 4 Apr 2016 11:40:28 -0400 Subject: [PATCH 063/665] - Add support for 'ssl_mode' options present in lib/pq - Update psotgresql provider's documentation - Enforce default value to 'require' for ssl_mode --- builtin/providers/postgresql/config.go | 3 ++- builtin/providers/postgresql/provider.go | 7 +++++++ .../source/docs/providers/postgresql/index.html.markdown | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/builtin/providers/postgresql/config.go b/builtin/providers/postgresql/config.go index 8bf7b2daa512..3d80ea6a15a6 100644 --- a/builtin/providers/postgresql/config.go +++ b/builtin/providers/postgresql/config.go @@ -13,6 +13,7 @@ type Config struct { Port int Username string Password string + SslMode string } // Client struct holding connection string @@ -23,7 +24,7 @@ type Client struct { //NewClient returns new client config func (c *Config) NewClient() (*Client, error) { - connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres", c.Host, c.Port, c.Username, c.Password) + connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres sslmode=%s", c.Host, c.Port, c.Username, c.Password, c.SslMode) client := Client{ connStr: connStr, diff --git a/builtin/providers/postgresql/provider.go b/builtin/providers/postgresql/provider.go index c048ec3ece76..8a8da8c8f48b 100644 --- a/builtin/providers/postgresql/provider.go +++ b/builtin/providers/postgresql/provider.go @@ -35,6 +35,12 @@ func Provider() terraform.ResourceProvider { DefaultFunc: schema.EnvDefaultFunc("POSTGRESQL_PASSWORD", nil), Description: "Password for postgresql server connection", }, + "ssl_mode": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "require", + Description: "Connection mode for postgresql server", + }, }, ResourcesMap: map[string]*schema.Resource{ @@ -52,6 +58,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { Port: d.Get("port").(int), Username: d.Get("username").(string), Password: d.Get("password").(string), + SslMode: d.Get("ssl_mode").(string), } client, err := config.NewClient() diff --git a/website/source/docs/providers/postgresql/index.html.markdown b/website/source/docs/providers/postgresql/index.html.markdown index 36761b626a36..0689e0ddc639 100644 --- a/website/source/docs/providers/postgresql/index.html.markdown +++ b/website/source/docs/providers/postgresql/index.html.markdown @@ -20,6 +20,7 @@ provider "postgresql" { port = 5432 username = "postgres_user" password = "postgres_password" + ssl_mode = "require" } ``` @@ -60,4 +61,5 @@ The following arguments are supported: * `host` - (Required) The address for the postgresql server connection. * `port` - (Optional) The port for the postgresql server connection. (Default 5432) * `username` - (Required) Username for the server connection. -* `password` - (Optional) Password for the server connection. \ No newline at end of file +* `password` - (Optional) Password for the server connection. +* `ssl_mode` - (Optional) Set connection mode for postgresql server (Default "require", more options [lib/pq documentations](https://godoc.org/github.com/lib/pq)). \ No newline at end of file From f840f49fbbf429b0918599c0d91897ec143687e0 Mon Sep 17 00:00:00 2001 From: Jeff LaPlante Date: Mon, 11 Apr 2016 10:23:19 -0700 Subject: [PATCH 064/665] Added support to read and update group attribute from existing vm state. --- .../resource_cloudstack_instance.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/builtin/providers/cloudstack/resource_cloudstack_instance.go b/builtin/providers/cloudstack/resource_cloudstack_instance.go index 75b1ce06ede0..fbc0c4860e35 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_instance.go +++ b/builtin/providers/cloudstack/resource_cloudstack_instance.go @@ -240,6 +240,8 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er d.Set("name", vm.Name) d.Set("display_name", vm.Displayname) d.Set("ipaddress", vm.Nic[0].Ipaddress) + d.Set("group", vm.Group) + //NB cloudstack sometimes sends back the wrong keypair name, so dont update it setValueOrID(d, "network", vm.Nic[0].Networkname, vm.Nic[0].Networkid) @@ -277,6 +279,26 @@ func resourceCloudStackInstanceUpdate(d *schema.ResourceData, meta interface{}) d.SetPartial("display_name") } + // Check if the group is changed and if so, update the virtual machine + if d.HasChange("group") { + log.Printf("[DEBUG] Group changed for %s, starting update", name) + + // Create a new parameter struct + p := cs.VirtualMachine.NewUpdateVirtualMachineParams(d.Id()) + + // Set the new group + p.SetGroup(d.Get("group").(string)) + + // Update the display name + _, err := cs.VirtualMachine.UpdateVirtualMachine(p) + if err != nil { + return fmt.Errorf( + "Error updating the group for instance %s: %s", name, err) + } + + d.SetPartial("group") + } + // Attributes that require reboot to update if d.HasChange("name") || d.HasChange("service_offering") || d.HasChange("keypair") { // Before we can actually make these changes, the virtual machine must be stopped From b44f7f28e083e8030f0c682067bd395f938493d5 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 11 Apr 2016 10:24:08 -0700 Subject: [PATCH 065/665] Document saved plan use in `terraform apply -help` (#6126) Wording borrowed from the website docs. --- command/apply.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/command/apply.go b/command/apply.go index 62ed3dd9ab0a..f18865bdb193 100644 --- a/command/apply.go +++ b/command/apply.go @@ -276,11 +276,16 @@ func (c *ApplyCommand) Synopsis() string { func (c *ApplyCommand) helpApply() string { helpText := ` -Usage: terraform apply [options] [DIR] +Usage: terraform apply [options] [DIR-OR-PLAN] Builds or changes infrastructure according to Terraform configuration files in DIR. + By default, apply scans the current directory for the configuration + and applies the changes appropriately. However, a path to another + configuration or an execution plan can be provided. Execution plans can be + used to only execute a pre-determined set of actions. + DIR can also be a SOURCE as given to the "init" command. In this case, apply behaves as though "init" was called followed by "apply". This only works for sources that aren't files, and only if the current working From 014f2d5671471e58cfbece31999189686d1476dc Mon Sep 17 00:00:00 2001 From: Jeff LaPlante Date: Mon, 11 Apr 2016 10:26:46 -0700 Subject: [PATCH 066/665] Added group attribute to cloudstack instance documentation markdown --- .../source/docs/providers/cloudstack/r/instance.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/source/docs/providers/cloudstack/r/instance.html.markdown b/website/source/docs/providers/cloudstack/r/instance.html.markdown index 1351ab107346..a78086f3180b 100644 --- a/website/source/docs/providers/cloudstack/r/instance.html.markdown +++ b/website/source/docs/providers/cloudstack/r/instance.html.markdown @@ -31,6 +31,8 @@ The following arguments are supported: * `display_name` - (Optional) The display name of the instance. +* `group` - (Optional) The group name of the instance. + * `service_offering` - (Required) The name or ID of the service offering used for this instance. From c5dbf1d04a0f9c0b89be0afa1e87db1e8736b6f8 Mon Sep 17 00:00:00 2001 From: captainill Date: Mon, 11 Apr 2016 13:02:15 -0500 Subject: [PATCH 067/665] annoucnement bnr --- website/.bundle/config | 3 +- website/Gemfile.lock | 3 - .../assets/stylesheets/_announcement-bnr.scss | 141 ++++++++++++++++++ .../assets/stylesheets/application.scss | 1 + website/source/layouts/_announcement-bnr.erb | 18 +++ website/source/layouts/_header.erb | 1 + website/source/layouts/_meta.erb | 2 +- .../source/layouts/svg/_svg-enterprise.erb | 41 +++++ 8 files changed, 204 insertions(+), 6 deletions(-) create mode 100755 website/source/assets/stylesheets/_announcement-bnr.scss create mode 100644 website/source/layouts/_announcement-bnr.erb create mode 100644 website/source/layouts/svg/_svg-enterprise.erb diff --git a/website/.bundle/config b/website/.bundle/config index df11c7518e0c..2fbf0ffd7101 100644 --- a/website/.bundle/config +++ b/website/.bundle/config @@ -1,2 +1 @@ ---- -BUNDLE_DISABLE_SHARED_GEMS: '1' +--- {} diff --git a/website/Gemfile.lock b/website/Gemfile.lock index f6cb5aa72698..b80006599e38 100644 --- a/website/Gemfile.lock +++ b/website/Gemfile.lock @@ -187,6 +187,3 @@ PLATFORMS DEPENDENCIES middleman-hashicorp! - -BUNDLED WITH - 1.11.2 diff --git a/website/source/assets/stylesheets/_announcement-bnr.scss b/website/source/assets/stylesheets/_announcement-bnr.scss new file mode 100755 index 000000000000..7520d828b838 --- /dev/null +++ b/website/source/assets/stylesheets/_announcement-bnr.scss @@ -0,0 +1,141 @@ +// +// announcement bnr +// -------------------------------------------------- + +$enterprise-bnr-font-weight: 300; +$enterprise-bnr-consul-color: #B52A55; +$enterprise-color-dark-white: #A9B1B5; + +body{ + // when _announcment-bnr.erb (ie. Consul Enterprise Announcment) is being used in layout we need to push down content to accomodate + // add this class to body + &.-displaying-bnr{ + #header{ + > .container{ + padding-top: 8px; + -webkit-transform: translateY(32px); + -ms-transform: translateY(32px); + transform: translateY(32px); + } + } + + #jumbotron { + .container{ + .jumbo-logo-wrap{ + margin-top: 160px; + } + } + } + + &.page-sub{ + #header{ + > .container{ + padding-bottom: 32px; + } + } + } + } +} + + +#announcement-bnr { + height: 40px; + flex-shrink: 0; + background-color: #000; + + &.-absolute{ + position: absolute; + top: 0; + left: 0; + width: 100%; + z-index: 9999; + } + + a,p{ + font-size: 14px; + color: $enterprise-color-dark-white; + font-family: $header-font-family; + font-weight: $enterprise-bnr-font-weight; + font-size: 13px; + line-height: 40px; + margin-bottom: 0; + } + + .link-highlight{ + display: inline-block; + margin-left: 3px; + color: lighten($purple, 10%); + font-weight: 400; + -webkit-transform: translateY(1px); + -ms-transform: translateY(1px); + transform: translateY(1px); + } + + .enterprise-logo{ + position: relative; + top: 4px; + + &:hover{ + text-decoration: none; + + svg{ + rect{ + fill: $enterprise-color-dark-white; + } + } + } + + svg{ + width: 156px; + fill: $white; + margin-right: 4px; + margin-left: 3px; + + rect{ + @include transition(all .1s ease-in); + } + } + } +} + +.hcaret{ + display: inline-block; + -moz-transform: translate(0, -1px) rotate(135deg); + -webkit-transform: translate(0, -1px) rotate(135deg); + transform: translate(0, -1px) rotate(135deg); + width: 7px; + height: 7px; + border-top: 1px solid lighten($purple, 10%); + border-left: 1px solid lighten($purple, 10%); + @include transition(all .1s ease-in); +} + +@media (max-width: 768px) { + #announcement-bnr { + .tagline{ + display: none; + } + } +} + +@media (max-width: 320px) { + #announcement-bnr { + a,p{ + font-size: 12px; + } + + .link-highlight{ + display: inline-block; + margin-left: 1px; + } + + .enterprise-logo svg{ + width: 128px; + margin-left: 2px; + } + + .hcaret{ + display: none; + } + } +} diff --git a/website/source/assets/stylesheets/application.scss b/website/source/assets/stylesheets/application.scss index 3776f905661a..27dd8558462d 100755 --- a/website/source/assets/stylesheets/application.scss +++ b/website/source/assets/stylesheets/application.scss @@ -22,6 +22,7 @@ @import 'hashicorp-shared/_hashicorp-sidebar'; // Components +@import '_announcement-bnr'; @import '_header'; @import '_footer'; @import '_jumbotron'; diff --git a/website/source/layouts/_announcement-bnr.erb b/website/source/layouts/_announcement-bnr.erb new file mode 100644 index 000000000000..4773605a682c --- /dev/null +++ b/website/source/layouts/_announcement-bnr.erb @@ -0,0 +1,18 @@ +
+
+
+
+

+ Announcing + + Collaborative Infrastructure Automation + + Find out more + +

+
+
+
+
diff --git a/website/source/layouts/_header.erb b/website/source/layouts/_header.erb index f6a3533533bb..8d98f7095d3f 100644 --- a/website/source/layouts/_header.erb +++ b/website/source/layouts/_header.erb @@ -1,4 +1,5 @@