From 89f1a38f5b362a903e2bae8c40c15c7342cd44d4 Mon Sep 17 00:00:00 2001 From: Sneha Somwanshi Date: Wed, 10 Dec 2014 16:09:14 +0530 Subject: [PATCH] added vpc tenancy argument --- builtin/providers/aws/resource_aws_vpc.go | 7 +++++ .../providers/aws/resource_aws_vpc_test.go | 28 +++++++++++++++++++ .../docs/providers/aws/r/vpc.html.markdown | 3 ++ 3 files changed, 38 insertions(+) diff --git a/builtin/providers/aws/resource_aws_vpc.go b/builtin/providers/aws/resource_aws_vpc.go index da04543ff..f64bb6e5b 100644 --- a/builtin/providers/aws/resource_aws_vpc.go +++ b/builtin/providers/aws/resource_aws_vpc.go @@ -24,6 +24,12 @@ func resourceAwsVpc() *schema.Resource { ForceNew: true, }, + "instance_tenancy": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "enable_dns_hostnames": &schema.Schema{ Type: schema.TypeBool, Optional: true, @@ -52,6 +58,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error { // Create the VPC createOpts := &ec2.CreateVpc{ CidrBlock: d.Get("cidr_block").(string), + InstanceTenancy: d.Get("instance_tenancy").(string), } log.Printf("[DEBUG] VPC create config: %#v", createOpts) vpcResp, err := ec2conn.CreateVpc(createOpts) diff --git a/builtin/providers/aws/resource_aws_vpc_test.go b/builtin/providers/aws/resource_aws_vpc_test.go index 4ef2e77aa..2b84ae16c 100644 --- a/builtin/providers/aws/resource_aws_vpc_test.go +++ b/builtin/providers/aws/resource_aws_vpc_test.go @@ -30,6 +30,26 @@ func TestAccVpc_basic(t *testing.T) { }) } +func TestAccVpc_dedicatedTenancy(t *testing.T) { + var vpc ec2.VPC + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckVpcDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccVpcDedicatedConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("aws_vpc.bar", &vpc), + resource.TestCheckResourceAttr( + "aws_vpc.bar", "instance_tenancy", "dedicated"), + ), + }, + }, + }) +} + func TestAccVpc_tags(t *testing.T) { var vpc ec2.VPC @@ -189,3 +209,11 @@ resource "aws_vpc" "foo" { } } ` +const testAccVpcDedicatedConfig = ` +resource "aws_vpc" "bar" { + instance_tenancy = "dedicated" + + cidr_block = "10.2.0.0/16" +} +` + diff --git a/website/source/docs/providers/aws/r/vpc.html.markdown b/website/source/docs/providers/aws/r/vpc.html.markdown index 489648d80..53611949b 100644 --- a/website/source/docs/providers/aws/r/vpc.html.markdown +++ b/website/source/docs/providers/aws/r/vpc.html.markdown @@ -25,6 +25,7 @@ Basic usage with tags: ``` resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" + instance_tenancy = "dedicated" tags { Name = "main" @@ -37,6 +38,7 @@ resource "aws_vpc" "main" { The following arguments are supported: * `cidr_block` - (Required) The CIDR block for the VPC. +* `instance_tenancy` - (Optional) A tenancy option for instances launched into the VPC * `enable_dns_support` - (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults true. * `enable_dns_hostnames` - (Optional) A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -47,6 +49,7 @@ The following attributes are exported: * `id` - The ID of the VPC * `cidr_block` - The CIDR block of the VPC +* `instance_tenancy` - Tenancy of instances spin up within VPC. * `enable_dns_support` - Whether or not the VPC has DNS support * `enable_dns_hostnames` - Whether or not the VPC has DNS hostname support * `main_route_table_id` - The ID of the main route table associated with