awslabs / fargatecli

CLI for AWS Fargate
Apache License 2.0
893 stars 114 forks source link

specify cluster using environment variable #45

Closed jritsema closed 6 years ago

jritsema commented 6 years ago

This allows the cluster to be specified using the environment variable, FARGATE_CLUSTER. This is useful if you're working with the tool and running a series of commands so that you don't have to keep typing the cluster for every command. For example:

export FARGATE_CLUSTER=my-cluster

fargate service info my-service
fargate service logs my-service
fargate service restart my-service
# etc

instead of

fargate --cluster my-cluster service info my-service
donwb commented 6 years ago

👍

jpignata commented 6 years ago

Thanks! Both this and #46 look like great approaches to me. One thought I did have was to incorporate a configuration file using https://github.com/spf13/viper which I think allows for environment variable overrides. That way there would be a uniform way to specify service name -- in fact people could check in a configuration file into their projects. We could always merge this approach and expand it later. What do you think?

jritsema commented 6 years ago

Ya, viper does look cool. Based on our current usage, I'm not sure having an additional config file to maintain would be worth it for the 2 variables (cluster and service) that we're currently using. My preference would probably be to go ahead and merge this now and then address a config file later.

By the way, I started iterating on #10 and I'm thinking that we might be able to specify cluster and service via labels in docker-compose.yml (when doing a deploy -f) since most of our users already maintain that "config" file (I will update the proposal on the other issue before submitting a PR).

jpignata commented 6 years ago

Understood on not wanting to use a config file for those. I do think however that it has support for using a environment variable for an override. I'll set aside some time this week to investigate.

Thanks on #10! looking forward to your thoughts.

jritsema commented 6 years ago

Hey, so after further iteration, I think I do like the idea of using viper to support both env vars and a config file after all. The nice thing about a config file is that (if using deploy -f) we can keep docker-compose.yml clean and free of any fargate info. Wondering about viper's rules around precedence. I think I would expect CLI args to override config file in the case where I want to deploy to a different cluster (we're doing a cluster per app environment).

jritsema commented 6 years ago

Closing since we've released this in our fork.

https://github.com/turnerlabs/fargate/releases/tag/v0.3.0