Code Monkey home page Code Monkey logo

Comments (5)

bblommers avatar bblommers commented on June 9, 2024 1

Hi @jrindy-iterable, thanks for raising this, and welcome to Moto!

We currently support the following filters:

  • zone-id
  • zone-type
  • zone-name
  • region-name

I'll mark it as an enhancement to also support the zone-id/zone-name parameters and the status filter.

from moto.

bblommers avatar bblommers commented on June 9, 2024

aws --endpoint=http://localhost:5000 ec2 describe-availability-zones --filters Name=zoneid,Values=use1-az4

Note that this doesn't work because of the typo in the name - it does work if you use Name=zone-id

from moto.

jrindy-iterable avatar jrindy-iterable commented on June 9, 2024

Got it. I assumed it was just zoneid due to it being ZoneId in the describe-availability-zones output. Thanks for the info there @bblommers, I was able to do a filter passing it in as zone-id.

That being said, I am hopeful that the enhancement will fix the bug I am seeing when using it with Terraform and the aws_availability_zone data source. Sample code here for reproduction with the providers.tf just pointing ec2 to moto-server:

# providers.tf
provider "aws" {
  region                      = "us-east-1"
  s3_use_path_style           = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    ec2 = "http://localhost:5000"
  }

  access_key = "my-access-key"
  secret_key = "my-secret-key"
}
# main.tf
data "aws_availability_zone" "test_id" {
  zone_id = "use1-az1"
  filter {
    name   = "state"
    values = ["available"]
  }
}

data "aws_availability_zone" "test_name" {
  name = "us-east-1b"
  filter {
    name   = "state"
    values = ["available"]
  }
}

This results in the following errors with Terraform:

 Error: multiple EC2 Availability Zones matched; use additional constraints to reduce matches to a single EC2 Availability Zone
│ 
│   with data.aws_availability_zone.test_id,
│   on az.tf line 1, in data "aws_availability_zone" "test_id":
│    1: data "aws_availability_zone" "test_id" {
│ 
╵
╷
│ Error: multiple EC2 Availability Zones matched; use additional constraints to reduce matches to a single EC2 Availability Zone
│ 
│   with data.aws_availability_zone.test_name,
│   on az.tf line 9, in data "aws_availability_zone" "test_name":
│    9: data "aws_availability_zone" "test_name" {

Thanks so much in advance for your help!

from moto.

bblommers avatar bblommers commented on June 9, 2024

@jrindy-iterable I've just ran your TF example, and the attached PR does indeed fix that problem.

It is now part of moto >= 4.2.12.dev20. Let us know if you run into any other issues!

from moto.

jrindy-iterable avatar jrindy-iterable commented on June 9, 2024

I swapped my compose to latest and gave it a try and it is filtering the AZ as expected now. Thanks again!

from moto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.