Merge pull request #637 from snehaso/vpc_tenanct

[AWS] added vpc instance_tenancy
This commit is contained in:
Armon Dadgar 2014-12-10 12:58:50 -08:00
commit 9668c8292f
3 changed files with 38 additions and 0 deletions

View File

@ -24,6 +24,12 @@ func resourceAwsVpc() *schema.Resource {
ForceNew: true, ForceNew: true,
}, },
"instance_tenancy": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"enable_dns_hostnames": &schema.Schema{ "enable_dns_hostnames": &schema.Schema{
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
@ -52,6 +58,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
// Create the VPC // Create the VPC
createOpts := &ec2.CreateVpc{ createOpts := &ec2.CreateVpc{
CidrBlock: d.Get("cidr_block").(string), CidrBlock: d.Get("cidr_block").(string),
InstanceTenancy: d.Get("instance_tenancy").(string),
} }
log.Printf("[DEBUG] VPC create config: %#v", createOpts) log.Printf("[DEBUG] VPC create config: %#v", createOpts)
vpcResp, err := ec2conn.CreateVpc(createOpts) vpcResp, err := ec2conn.CreateVpc(createOpts)

View File

@ -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) { func TestAccVpc_tags(t *testing.T) {
var vpc ec2.VPC 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"
}
`

View File

@ -25,6 +25,7 @@ Basic usage with tags:
``` ```
resource "aws_vpc" "main" { resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16" cidr_block = "10.0.0.0/16"
instance_tenancy = "dedicated"
tags { tags {
Name = "main" Name = "main"
@ -37,6 +38,7 @@ resource "aws_vpc" "main" {
The following arguments are supported: The following arguments are supported:
* `cidr_block` - (Required) The CIDR block for the VPC. * `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_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. * `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. * `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 * `id` - The ID of the VPC
* `cidr_block` - The CIDR block 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_support` - Whether or not the VPC has DNS support
* `enable_dns_hostnames` - Whether or not the VPC has DNS hostname 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 * `main_route_table_id` - The ID of the main route table associated with