Hello, I’m trying to create ECR lifecycle polices ...
# python
a
Hello, I’m trying to create ECR lifecycle polices and I’m following this doc. I have the latest pulumi_aws version (6.37.0) but when I try to execute. the cli is erroring with
Copy code
error: Program failed with an unhandled exception:
    Traceback (most recent call last):

File "<frozen importlib.util>", line 204, in __getattribute__
    AttributeError: module 'pulumi_aws.ecr' has no attribute 'get_lifecycle_policy_document'
Am I missing something? Is the doc outdated? Thank you
l
Hi Vincent. Do you know what version of
pulumi_aws
you are using? E.g. what is listed in your
requirements.txt
?
a
Copy code
pulumi==3.116.1
pulumi_aws==6.37.0
pulumi_aws_native==0.106.0
pulumi_eks==2.2.1
pulumi_kubernetes==4.9.1
l
Hm, that function should definitely be there. Are you able to post a more complete snippet of your program?
a
Copy code
import pulumi
import pulumi_aws as aws
import pulumi_aws_native as aws_native

...

lifecycle_policy_rule_document = aws.ecr.get_lifecycle_policy_document(rules=[aws.ecr.GetLifecyclePolicyDocumentRuleArgs(
    priority=1,
    description="Keep last 5 images",
    selection=aws.ecr.GetLifecyclePolicyDocumentRuleSelectionArgs(
        tag_status="tagged",
        tag_prefix_lists=["*"],
        count_type="imageCountMoreThan",
        count_number=5)
)])
l
Hm I'm unable to reproduce this using the requirements you've given and that example code. My only hypotheses are: • Are your installed packages up-to-date with your
requirements.txt
? • Do you perhaps declare an
aws
variable elsewhere in your program (e.g. a provider)?
a
I still couldn’t get it to work with the above. i ending up using the function
aws.ecr.LifecyclePolicy
and just encoding the policy myself
Thanks for taking a look, I appreciate it.
l
No worries -- this is still perplexing to me though, I will see if there are any similar reports.