Currently, AWS CodeCommit is only available in us-east-1, therefore we

need to error out early if the region is anything other than this

Also added a test that will show that changes get applied on subsequent
runs
This commit is contained in:
stack72 2015-09-18 09:54:14 +01:00
parent d9fd77c141
commit 2ad006ab50
2 changed files with 40 additions and 0 deletions

View File

@ -74,6 +74,13 @@ func resourceAwsCodeCommitRepository() *schema.Resource {
func resourceAwsCodeCommitRepositoryCreate(d *schema.ResourceData, meta interface{}) error {
codecommitconn := meta.(*AWSClient).codecommitconn
region := meta.(*AWSClient).region
// This is a temporary thing - we need to ensure that CodeCommit is only being run against us-east-1
// As this is the only place that AWS currently supports it
if region != "us-east-1" {
return fmt.Errorf("CodeCommit can only be used with US-East-1")
}
input := &codecommit.CreateRepositoryInput{
RepositoryName: aws.String(d.Get("repository_name").(string)),

View File

@ -26,6 +26,32 @@ func TestAccAWSCodeCommitRepository_basic(t *testing.T) {
})
}
func TestAccAWSCodeCommitRepository_withChanges(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCodeCommitRepositoryDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCodeCommitRepository_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckCodeCommitRepositoryExists("aws_codecommit_repository.test"),
resource.TestCheckResourceAttr(
"aws_codecommit_repository.test", "description", "This is a test description"),
),
},
resource.TestStep{
Config: testAccCodeCommitRepository_withChanges,
Check: resource.ComposeTestCheckFunc(
testAccCheckCodeCommitRepositoryExists("aws_codecommit_repository.test"),
resource.TestCheckResourceAttr(
"aws_codecommit_repository.test", "description", "This is a test description - with changes"),
),
},
},
})
}
func testAccCheckCodeCommitRepositoryExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
@ -74,3 +100,10 @@ resource "aws_codecommit_repository" "test" {
description = "This is a test description"
}
`
const testAccCodeCommitRepository_withChanges = `
resource "aws_codecommit_repository" "test" {
repository_name = "my_test_repository"
description = "This is a test description - with changes"
}
`