mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Add support for instance tenancy in aws_opsworks_instance
(#10885)
This commit is contained in:
parent
1df2cf7d6b
commit
dd807c79ff
@ -276,6 +276,13 @@ func resourceAwsOpsworksInstance() *schema.Resource {
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"tenancy": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateTenancy,
|
||||
},
|
||||
|
||||
"virtualization_type": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@ -429,6 +436,15 @@ func validateArchitecture(v interface{}, k string) (ws []string, errors []error)
|
||||
return
|
||||
}
|
||||
|
||||
func validateTenancy(v interface{}, k string) (ws []string, errors []error) {
|
||||
value := v.(string)
|
||||
if value != "dedicated" && value != "default" && value != "host" {
|
||||
errors = append(errors, fmt.Errorf(
|
||||
"%q must be one of \"dedicated\", \"default\" or \"host\"", k))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAutoScalingType(v interface{}, k string) (ws []string, errors []error) {
|
||||
value := v.(string)
|
||||
if value != "load" && value != "timer" {
|
||||
@ -561,6 +577,7 @@ func resourceAwsOpsworksInstanceRead(d *schema.ResourceData, meta interface{}) e
|
||||
d.Set("stack_id", instance.StackId)
|
||||
d.Set("status", instance.Status)
|
||||
d.Set("subnet_id", instance.SubnetId)
|
||||
d.Set("tenancy", instance.Tenancy)
|
||||
d.Set("virtualization_type", instance.VirtualizationType)
|
||||
|
||||
// Read BlockDeviceMapping
|
||||
@ -646,6 +663,10 @@ func resourceAwsOpsworksInstanceCreate(d *schema.ResourceData, meta interface{})
|
||||
req.SubnetId = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("tenancy"); ok {
|
||||
req.Tenancy = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("virtualization_type"); ok {
|
||||
req.VirtualizationType = aws.String(v.(string))
|
||||
}
|
||||
@ -800,6 +821,10 @@ func resourceAwsOpsworksInstanceUpdate(d *schema.ResourceData, meta interface{})
|
||||
req.SshKeyName = aws.String(v.(string))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("tenancy"); ok {
|
||||
req.Tenancy = aws.String(v.(string))
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Updating OpsWorks instance: %s", d.Id())
|
||||
|
||||
_, err = client.UpdateInstance(req)
|
||||
|
@ -44,6 +44,9 @@ func TestAccAWSOpsworksInstance(t *testing.T) {
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_opsworks_instance.tf-acc", "architecture", "x86_64",
|
||||
),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_opsworks_instance.tf-acc", "tenancy", "default",
|
||||
),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2014.09", // inherited from opsworks_stack_test
|
||||
),
|
||||
@ -73,6 +76,9 @@ func TestAccAWSOpsworksInstance(t *testing.T) {
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2015.09",
|
||||
),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_opsworks_instance.tf-acc", "tenancy", "default",
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
@ -125,6 +131,9 @@ func testAccCheckAWSOpsworksInstanceAttributes(
|
||||
if *opsinst.Architecture != "x86_64" {
|
||||
return fmt.Errorf("Unexpected architecture: %s", *opsinst.Architecture)
|
||||
}
|
||||
if *opsinst.Tenancy != "default" {
|
||||
return fmt.Errorf("Unexpected tenancy: %s", *opsinst.Tenancy)
|
||||
}
|
||||
if *opsinst.InfrastructureClass != "ec2" {
|
||||
return fmt.Errorf("Unexpected infrastructure class: %s", *opsinst.InfrastructureClass)
|
||||
}
|
||||
|
3
vendor/github.com/aws/aws-sdk-go/service/opsworks/api.go
generated
vendored
3
vendor/github.com/aws/aws-sdk-go/service/opsworks/api.go
generated
vendored
@ -14069,6 +14069,9 @@ type UpdateInstanceInput struct {
|
||||
|
||||
// The instance's Amazon EC2 key name.
|
||||
SshKeyName *string `type:"string"`
|
||||
|
||||
// The instance's placement tenancy.
|
||||
Tenancy *string `type:"string"`
|
||||
}
|
||||
|
||||
// String returns the string representation
|
||||
|
@ -47,6 +47,7 @@ The following arguments are supported:
|
||||
* `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
|
||||
* `tenancy` - (Optional) Instance tenancy to use. Can be one of `"default"`, `"dedicated"` or `"host"`
|
||||
* `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
|
||||
@ -128,5 +129,6 @@ The following attributes are exported:
|
||||
for your VPC
|
||||
* `private_ip` - The private IP address assigned to the instance
|
||||
* `subnet_id` - The VPC subnet ID.
|
||||
* `tenancy` - The Instance tenancy
|
||||
* `security_group_ids` - The associated security groups.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user