provider/aws: Add support for the `repository_url` to be computed for
ECR
This commit is contained in:
parent
5d9637ab1a
commit
7c5ab40b74
|
@ -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
|
||||
|
||||
|
|
|
@ -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`
|
||||
|
|
Loading…
Reference in New Issue