wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.98k stars 263 forks source link

Import template variables from another file(s) #121

Open Shemeikka opened 7 years ago

Shemeikka commented 7 years ago

Idea: Allow importing template variables from another file(s).

Use case: Allows supporting multiple environments (i.e. dev, test, etc.) Better automation support.

Example:

.
|-- dev
    |-- variables.awless
|-- test
    |-- variables.awless
|--modules
    |-- ec2
        |-- security_groups
            |-- ssh_from_internet.awless

Importing could be done either using cli argument

awless run modules/ec2/security_groups/ssh_from_internet.awless --import dev/variables.awless

or inside the actual file

import dev/variables.awless
securitygroup = create securitygroup name="SSH from Internet" vpn=$vpc-id description="Allows SSH connections"

This would be extremely useful for e.q. setting instance counts per environment.

simcap commented 7 years ago

Thanks. This is definitely a good idea.

At this point supporting pointing to a variables file from the CLI might be more feasible than an import keyword since we will be soon in the process of reinforcing/improving our template language.

Note that this external import file might be more scalable and help our current config template defaults (view them with awless config). Currently, you can actually set any value in config that will be used as default in templates:

awless config set topic.name mytopicname (will be used each time in the awless create topic for the name)

But indeed those persisted defaults might not be obvious (you have to prepend the entity name) and are different from dynamic env variables.

We want to do that properly so we will discuss about that and see where we want to take it @fxaguessy @hbbio

In the meantime, a --import-vars flag when running template could help I think without breaking anything and while making clear that we only import variables (instead of putting them at the top of each file).

simcap commented 7 years ago

@Shemeikka we try to focus awless on real life usage (as we do here internally). It would be great if you had a look at this short Google form https://goo.gl/forms/1lQFPEIxdt37aDn43

Cheers.