Closed jazzdan closed 1 year ago
Error creating ECR Registry Policy: InvalidParameterException: Invalid parameter at 'PolicyText' failed to satisfy constraint: 'Invalid registry policy provided'
Ugh, that's pretty unhelpful error text, isn't it -- sorry about that. I suspect it's passed through from the AWS API (since it's an opaque string to the provider). But still, it would be nice to do better.
One thing I noticed on a scan is that the example at https://www.pulumi.com/registry/packages/aws/api-docs/ecr/registrypolicy/#example-usage includes a Resource
field in the stringified policy, whereas your code above doesn't. The examples in the AWS docs (if I have the right place ...) include a Resource field too. Could that be the problem?
I noticed that the Pulumi API for RegistryPolicy doesn’t take a repository ID, only a policy (https://www.pulumi.com/registry/packages/aws/api-docs/ecr/registrypolicy/#create). Whereas the terraform API takes both a repository ID and a policy (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy#argument-reference).
These are two different things with very easily confusable names: RegistryPolicy (applies to the whole registry), and RepositoryPolicy (applies to a particular image repository in a registry). The Pulumi SDK equivalent to the Terraform resource is https://www.pulumi.com/registry/packages/aws/api-docs/ecr/repositorypolicy/, which does have a repository
input.
Ah, thanks @squaremo you're totally right. Switching to repository policy is what I needed to do. Thanks so much!!!
What happened?
Whenever I try to create a AWS Elastic Container Registry Policy I get the following error:
Steps to reproduce
Expected Behavior
I expected an ecr RegistryPolicy to be created
Actual Behavior
Output of
pulumi about
Additional context
I noticed that the Pulumi API for RegistryPolicy doesn’t take a repository ID, only a policy (https://www.pulumi.com/registry/packages/aws/api-docs/ecr/registrypolicy/#create). Whereas the terraform API takes both a repository ID and a policy (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy#argument-reference). Is it possible that this Pulumi API is wrong and it’s impossible to make AWS ECR Registry Policies or am I missing something? I don’t see how Pulumi could know what repository to apply this policy to without a registry/repository ID.
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).