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

feature request: support target file with array #17285

Open
GeoffMillerAZ opened this issue Feb 6, 2018 · 1 comment
Open

feature request: support target file with array #17285

GeoffMillerAZ opened this issue Feb 6, 2018 · 1 comment

Comments

@GeoffMillerAZ
Copy link

Feature Request: support target file with array

Consider

I have found the --target=path to be incredibly useful but many times I would like to perform one operation that targets more than one resource and, often, order would be important. To solve this I'd have to write multiple terraform commands in a bash script and execute. What if I could do something like:

terraform apply --target-file=create_iam.yml

where create_iam.yml file contents:

target:
- module.packer.aws_iam_account_alias.current
- module.packer.aws_iam_instance_profile.default
- module.packer.aws_iam_policy.packer_s3_user_data
- module.packer.aws_iam_policy_document.packer_role
- module.packer.aws_iam_policy_document.packer_s3_user_data
- module.packer.aws_iam_role.packer
- module.packer.aws_iam_role_policy_attachment.packer_cw_ec2
- module.packer.aws_iam_role_policy_attachment.packer_s3_user_data
- module.openvpn.aws_iam_instance_profile.openvpn
- module.openvpn.aws_iam_policy_document.openvpn_role
- module.openvpn.aws_iam_role.openvpn
- module.openvpn.aws_iam_role_policy_attachment.openvpn_cw_ec2

Extra Consideration

This request is especially important with the absence of module dependencies and it seems like this would be much easier to implement and could solve the problem of no module dependencies as well as give useful functionality that would improve terraform even if module dependency mapping were available. I am currently running a series of terraform targeted apply statements to get around not having module dependency mapping but I would still do this anyway. For instance, what if I want to delete everything but the VPC or stand up only part of my environment?

Bonus

It would be even nicer if you could have wildcard characters like #2182 requests and inverse targeting like #2253 requests. Negative applies could be started with !.

example:

target:
- !.module.bastion.* # first, apply everything but bastion module or what depends on it
- module.bastion.aws_iam_policy_document.* # then do all iam policies
- module.bastion.aws_iam_role.* # then do all iam roles
- * # do a full terraform apply

The examples I provided are meant to show how the feature would work and not why it is needed. They were the best I could come up with. My actual code is much more complex and I didn't want to have to write a novel.

Related issues

allow -target to accept globs #2182
feature request: inverse targeting / exclude #2253

@apparentlymart
Copy link
Contributor

Thanks for opening this, @GeoffMillerAZ!

The Terraform team at HashiCorp is currently focused on configuration language improvements, but we intend to shift our focus to CLI enhancements once we complete the current set of work. At that time we'll review this again and see how it fits in with other possible improvements, including the ones you specifically mentioned here.

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

No branches or pull requests

2 participants