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

Support for yaml api body #22

Open
tibbing opened this issue Aug 25, 2022 · 1 comment
Open

Support for yaml api body #22

tibbing opened this issue Aug 25, 2022 · 1 comment

Comments

@tibbing
Copy link

tibbing commented Aug 25, 2022

It would be nice if we could also support yaml format API body. Currently doing the jsonencode(..) here restricts us to only providing a OpenAPI map:

body = jsonencode(var.openapi_config)

But aws_api_gateway_rest_api actually accepts a yaml string just as well. I.e. the following works:

data "template_file" "swagger_api" {
  template = file("./swagger.yaml")
  vars = {
    ...
  }
}

resource "aws_api_gateway_rest_api" "this" {
  count = local.enabled ? 1 : 0

  name = module.this.id
  body = data.template_file.swagger_api.rendered
  tags = module.this.tags

  endpoint_configuration {
    types = [var.endpoint_type]
  }
}

The easiest solution would probably be to just remove the jsonencode() part and let the caller do that if needed. Optionally we could add another variable instead for backwards compatibility.

Another upside to getting rid of the jsonencode is supporting the case where the caller already has the body as json, for example when reading a json file.

@susie-idw
Copy link

I'm able to do...
openapi_config = yamldecode(file("${get_terragrunt_dir()}/vars/infra1-io.yaml"))
I export from aws as a yaml formatted file.

Not your request, but could help in the meantime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants