atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Fast outputs of components by reading remote state directly without `terraform output`

Open nitrocode opened this issue 3 years ago • 2 comments

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

The current way to get component outputs is to use this method

atmos terraform outputs eks --stack ue2-sandbox

which will run the following commands

atmos generate backend
terraform init -reconfigure
terraform output

This can take a long time and atmos already knows the s3 bucket, the s3 bucket key, and the workspace

A faster method could be used for atmos terraform stack outputs or something where it simply does the following

aws s3 cp s3://<bucket-name>/<component workspace key prefix>/<component name>/terraform.tfstate - | jq .outputs
{
  "transit_gateway_arn": {
    "value": "arn:aws:ec2:us-east-2:snip:transit-gateway/tgw-snip",
    "type": "string"
  },
  "transit_gateway_id": {
    "value": "tgw-snip",
    "type": "string"
  },
  "transit_gateway_route_table_id": {
    "value": "tgw-rtb-snip",
    "type": "string"
  }
}

or use some jq magic to turn it into this

transit_gateway_arn = "arn:aws:ec2:us-east-2:snip:transit-gateway/tgw-snip"
transit_gateway_id = "tgw-snip"
transit_gateway_route_table_id = "tgw-rtb-snip"

nitrocode avatar Jul 31 '22 21:07 nitrocode

@nitrocode maybe this is a good feature to prototype with atmos custom CLI commands?

https://github.com/cloudposse/atmos/pull/168

I don't think we can implement this in atmos core because it assumes (a) using our tfstate backend (b) using S3 (c) using AWS. Atmos needs to be cloud agnostic.

osterman avatar Aug 01 '22 19:08 osterman

Maybe this relates to @Gowiem's request: https://github.com/cloudposse/atmos/issues/178

osterman avatar Aug 01 '22 19:08 osterman