Does anyone here has a working example how to use ...
# python
p
Does anyone here has a working example how to use the aws.ec2.get_ami()? I've followed the instructions in the workshop here, the docs here even the Pulumi AI with the following code provided. They all fail with errors like empty results, or ValueError: unexpected input of type GetAmiResult. What's my mistake, it shouldn't be this hard.
Copy code
import pulumi
import pulumi_aws as aws

# Retrieve the latest Amazon Linux AMI in the 'us-east-2' region
latest_amazon_linux_ami = aws.ec2.get_ami(
    most_recent=True,
    owners=["amazon"],
    filters=[
        aws.ec2.GetAmiFilterArgs(
            name="name",
            values=["amzn2-ami-hvm-*-x86_64-gp2"],
        ),
    ],
)

# Use the AMI ID
pulumi.export('ami_id', latest_amazon_linux_ami.id)
Nevermind....it's one of those the errors are not clear enough issues. The problem was that when creating the Instance, instead of using ami=self.ami.id I was using ami=self.ami.