provider/aws: Add support for the `repository_url` to be computed for

ECR
This commit is contained in:
stack72 2016-03-08 23:51:30 +00:00
parent 5d9637ab1a
commit 7c5ab40b74
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`