github.com/rhenning/terraform@v0.8.0-beta2/builtin/providers/aws/resource_aws_opsworks_user_profile_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/acctest"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccAWSOpsworksUserProfile(t *testing.T) {
    12  	rName := fmt.Sprintf("test-user-%d", acctest.RandInt())
    13  	roleName := fmt.Sprintf("tf-ops-user-profile-%d", acctest.RandInt())
    14  	resource.Test(t, resource.TestCase{
    15  		PreCheck:  func() { testAccPreCheck(t) },
    16  		Providers: testAccProviders,
    17  		Steps: []resource.TestStep{
    18  			resource.TestStep{
    19  				Config: testAccAwsOpsworksUserProfileCreate(rName, roleName),
    20  				Check: resource.ComposeTestCheckFunc(
    21  					resource.TestCheckResourceAttr(
    22  						"aws_opsworks_user_profile.user", "ssh_public_key", "",
    23  					),
    24  					resource.TestCheckResourceAttr(
    25  						"aws_opsworks_user_profile.user", "ssh_username", rName,
    26  					),
    27  					resource.TestCheckResourceAttr(
    28  						"aws_opsworks_user_profile.user", "allow_self_management", "false",
    29  					),
    30  				),
    31  			},
    32  		},
    33  	})
    34  }
    35  
    36  func testAccAwsOpsworksUserProfileCreate(rn, roleName string) string {
    37  	return fmt.Sprintf(`
    38  resource "aws_opsworks_user_profile" "user" {
    39    user_arn = "${aws_iam_user.user.arn}"
    40    ssh_username = "${aws_iam_user.user.name}"
    41  }
    42  
    43  resource "aws_iam_user" "user" {
    44  	name = "%s"
    45  	path = "/"
    46  }
    47  
    48  %s
    49  	`, rn, testAccAwsOpsworksStackConfigNoVpcCreate(roleName))
    50  }