Merge pull request #540 from snehaso/master

AWS instance resource now supports tenancy
This commit is contained in:
Seth Vargo 2014-12-03 10:02:47 -05:00
commit b8d20960ff
2 changed files with 27 additions and 0 deletions

View File

@ -125,6 +125,12 @@ func resourceAwsInstance() *schema.Resource {
ForceNew: true,
Optional: true,
},
"tenancy": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"tags": tagsSchema(),
"block_device": &schema.Schema{
@ -202,6 +208,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
UserData: []byte(userData),
EbsOptimized: d.Get("ebs_optimized").(bool),
IamInstanceProfile: d.Get("iam_instance_profile").(string),
Tenancy: d.Get("tenancy").(string),
}
if v := d.Get("security_groups"); v != nil {
@ -326,6 +333,7 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("subnet_id", instance.SubnetId)
d.Set("ebs_optimized", instance.EbsOptimized)
d.Set("tags", tagsToMap(instance.Tags))
d.Set("tenancy", instance.Tenancy)
// Determine whether we're referring to security groups with
// IDs or names. We use a heuristic to figure this out. By default,

View File

@ -3,8 +3,10 @@ package aws
import (
"fmt"
"testing"
"reflect"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/goamz/ec2"
)
@ -247,6 +249,22 @@ func testAccCheckInstanceExists(n string, i *ec2.Instance) resource.TestCheckFun
}
}
func TestInstanceTenancySchema(t *testing.T) {
actualSchema := resourceAwsInstance().Schema["tenancy"]
expectedSchema := &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
}
if !reflect.DeepEqual(actualSchema, expectedSchema ) {
t.Fatalf(
"Got:\n\n%#v\n\nExpected:\n\n%#v\n",
actualSchema,
expectedSchema)
}
}
const testAccInstanceConfig = `
resource "aws_security_group" "tf_test_foo" {
name = "tf_test_foo"
@ -338,6 +356,7 @@ resource "aws_instance" "foo" {
instance_type = "m1.small"
subnet_id = "${aws_subnet.foo.id}"
associate_public_ip_address = true
tenancy = "dedicated"
}
`