Merge pull request #5524 from stack72/f-aws-ecr-repository_name

provider/aws: `repository_url` is computed for `aws_ecr_repository`
This commit is contained in:
Paul Stack 2016-03-09 09:38:09 +00:00
commit 4601d371e1
2 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package aws
import (
"log"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ecr"
@ -29,6 +31,10 @@ func resourceAwsEcrRepository() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"repository_url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
@ -81,9 +87,17 @@ func resourceAwsEcrRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("arn", *repository.RepositoryArn)
d.Set("registry_id", *repository.RegistryId)
repositoryUrl := buildRepositoryUrl(repository, meta.(*AWSClient).region)
log.Printf("[INFO] Setting the repository url to be %s", repositoryUrl)
d.Set("repository_url", repositoryUrl)
return nil
}
func buildRepositoryUrl(repo *ecr.Repository, region string) string {
return fmt.Sprintf("https://%s.dkr.ecr.%s.amazonaws.com/%s", *repo.RegistryId, region, *repo.RepositoryName)
}
func resourceAwsEcrRepositoryDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ecrconn

View File

@ -37,3 +37,4 @@ The following attributes are exported:
* `arn` - Full ARN of the repository.
* `name` - The name of the repository.
* `registry_id` - The registry ID where the repository was created.
* `repository_url` - The URL of the repository (in the form `https://aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName`