Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: repository_url is computed for aws_ecr_repository #5524

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions builtin/providers/aws/resource_aws_ecr_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,6 +31,10 @@ func resourceAwsEcrRepository() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"repository_url": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why https ? just return fmt.Sprintf("%s.dkr.ecr.%s.amazonaws.com/%s", *repo.RegistryId, region, *repo.RepositoryName) is okay!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same issue. I'd like to use this in a container definition template and the HTTPS breaks it.

}

func resourceAwsEcrRepositoryDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ecrconn

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`