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

Enhancement: Don't define provider blocks inside the scenarios #115

Open
christophetd opened this issue Dec 29, 2021 · 2 comments
Open

Enhancement: Don't define provider blocks inside the scenarios #115

christophetd opened this issue Dec 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@christophetd
Copy link
Contributor

Terraform best practices dictate that a module shouldn't define its own provider configuration, unless it needs something specific.

An enhancement would be to not define the AWS provider in every scenario. It would also make it easier to perform refactorings like #101

@RyanJarv
Copy link
Contributor

RyanJarv commented Jan 10, 2022

Was just thinking about this and I'm thinking this might work:

Have a parent tf project which contains the provider config, this file doesn't need to change during the cloadgoat lifecycle so it can be edited by the user if needed. When a scenario is enabled we write a file out in the same project which includes the specific scenario as a module, when it's deleted that file is deleted. Terraform apply is then run in this parent directory but otherwise the same as before.

@RyanJarv RyanJarv added the enhancement New feature or request label Jan 10, 2022
@andrew-aiken
Copy link
Contributor

I don't think the python script calls the Terraform code as a module.

The instance_path is cloudgoat/glue_privesc_cgid5ztu3nelrx which contains just the scenario code

terraform = Terraform(
            working_dir=os.path.join(instance_path, "terraform")
)

...

apply_retcode, apply_stdout, apply_stderr = terraform.apply(
            capture_output=False,
            var=tf_vars,
            skip_plan=True,
            no_color=IsNotFlagged,
)

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

No branches or pull requests

3 participants