Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
Terraform error "Your query returned no results"

I have below bom-asg.tf file.

data "aws_ami" "bom-ami" {
most_recent = true

  filter {
    name   = "tag:ami_name"
    values = ["${var.environment}-bom-ami"]
  }

  owners = ["****"]
}

resource "aws_security_group" "bom-sg" {
  name_prefix = "${var.environment}-bom-asg-sg"
  vpc_id      = "${var.vpc_id}"
  .....

I am unable to successfully execute refresh and plan commands. I am getting below errors.

terraform plan --var-file=environment-parity.tfvars -target=bom-asg.tf --out apply.out
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.


------------------------------------------------------------------------

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.

But when I run refresh. I am getting below error.

terraform refresh --var-file=environment-parity.tfvars
data.template_file.es_access_policy_search: Refreshing state...
data.aws_ami.nginx-ami: Refreshing state...
data.aws_ami.php-search-ami: Refreshing state...
data.aws_ami.ng-ami: Refreshing state...
data.aws_ami.mysql-ami: Refreshing state...
data.aws_ami.frontend-search-ami: Refreshing state...
data.aws_ami.bom-ami: Refreshing state...
data.aws_ami.lg-ami: Refreshing state...
data.aws_ami.rabbitmq-search-ami: Refreshing state...
data.aws_ami.ngas-ng-drupal-ami: Refreshing state...
data.aws_ami.mongodb-ami: Refreshing state...

Error: Error refreshing state: 1 error(s) occurred:

* data.aws_ami.bom-ami: 1 error(s) occurred:

* data.aws_ami.bom-ami: data.aws_ami.bom-ami: Your query returned no results. Please change your search criteria and try again.

Can you please help?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Terraform data source is to access an existing resource, not to create one.

data "aws_ami" "bom-ami"

As in the documentation, the AMI needs to exist already.

  • Data Source: aws_ami

Use this data source to get the ID of a registered AMI for use in other resources.

If you are creating an AMI from an EBS snapshot taken from an EC2 instance (e.g. Amazon Linux EC2), then:

  • Resource: aws_ami

Please note the difference between data and resource.

To create a custom AMI image, please also consider Hashicorp packer.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda