From 2ad006ab50e24b80aa6e997105bc417ddbdd72b9 Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 18 Sep 2015 09:54:14 +0100 Subject: [PATCH] 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 --- .../aws/resource_aws_codecommit_repository.go | 7 ++++ ...resource_aws_codecommit_repository_test.go | 33 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/builtin/providers/aws/resource_aws_codecommit_repository.go b/builtin/providers/aws/resource_aws_codecommit_repository.go index f1830864e..3f15ac409 100644 --- a/builtin/providers/aws/resource_aws_codecommit_repository.go +++ b/builtin/providers/aws/resource_aws_codecommit_repository.go @@ -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)), diff --git a/builtin/providers/aws/resource_aws_codecommit_repository_test.go b/builtin/providers/aws/resource_aws_codecommit_repository_test.go index 7859e0d82..14fcdf321 100644 --- a/builtin/providers/aws/resource_aws_codecommit_repository_test.go +++ b/builtin/providers/aws/resource_aws_codecommit_repository_test.go @@ -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" +} +`