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

Terraform: List of AMI specific to ubuntu 20.04 LTS AWS #15150

Closed
sudlo opened this issue Sep 15, 2020 · 3 comments
Closed

Terraform: List of AMI specific to ubuntu 20.04 LTS AWS #15150

sudlo opened this issue Sep 15, 2020 · 3 comments
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@sudlo
Copy link

sudlo commented Sep 15, 2020

I am using terraform to get a list of AMI for a specific OS - ubuntu 20.04,

I have checked different examples link

When I use the script this does not give me list of AMI. So i modified the code

data "aws_ami" "ubuntu" {

    most_recent = true

    filter {
        name   = "name"
        values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
    }

    filter {
        name = "virtualization-type"
        values = ["hvm"]
    }

    owners = ["099720109477"]
}

However, ideally this should give me the details of ami in the region specified in my case us-east-1.

[ec2-user@ip-172-31-84-148 ~]$ terraform plan
provider.aws.region
The region where AWS operations will take place. Examples
are us-east-1, us-west-2, etc.

Enter a value: us-east-1

Refreshing Terraform state in-memory prior to plan…
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_ami.ubuntu: Refreshing state…

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

and also i am not sure how create an out for the above script. i am not very good in terraform. Please guide me where am i going wrong.

Note: I really am not sure whether this is a bug or ... a question..

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Sep 15, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 15, 2020
@dthvt
Copy link
Contributor

dthvt commented Sep 15, 2020

If your terraform only has the data block in it, there is no resource being controlled by terraform and thus there will never be a change reported.

If you want terraform to output information about the AMI, you will have to add an output block similar to this:

output "ubuntu_ami" {
  value = data.aws_ami.ubuntu
}

If you are new to terraform, you may want to review some of the tutorials at https://learn.hashicorp.com/collections/terraform/aws-get-started

Cheers!

@anGie44 anGie44 added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 15, 2020
@sudlo
Copy link
Author

sudlo commented Sep 15, 2020

@dthvt Thank you so much sir.

Let me try this. I will get back to you . If there is any kind of issues..

Thanks for your time and patience.

@sudlo sudlo closed this as completed Sep 15, 2020
@ghost
Copy link

ghost commented Oct 16, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

3 participants