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

Error: changes to lifecycle_commands and/or interpreter should not be follwed by changes to other arguments #106

Open
vknemanavar opened this issue Feb 24, 2022 · 4 comments

Comments

@vknemanavar
Copy link

we are using shell_script resource to create IBM VPN server, first time creation resource creation worked perfectly but second time when we run plan getting below error
Error: changes to lifecycle_commands and/or interpreter should not be follwed by changes to other arguments

Here is our TF code
resource "shell_script" "vpn_server_route" {

lifecycle_commands {
create = file("${path.module}/scripts/create-vpn-route.sh")
read = file("${path.module}/scripts/read-vpn-route.sh")
delete = file("${path.module}/scripts/delete-vpn-route.sh")
}

environment = {
REGION = var.region
RESOURCE_GROUP = var.resource_group_name
VPC_NAME = var.vpc_name
VPN_SERVER_NAME = var.vpn_instance_name
API_KEY = var.ibmcloud_api_key

VPN_ROUTE_NAME        = var.vpn_route_name != "" ? var.vpn_route_name : "${var.vpn_instance_name}-default-route"
VPN_ROUTE_DESTINATION = var.vpn_route_destination
VPN_ROUTE_ACTION      = var.vpn_route_action

}

working_directory = path.module

}

@richardj-bsquare
Copy link

Yes, this is irksome for me also, since I'm using the shell resource to do git manipulation across multiple repositories. The environment contains a hash (of git ls-remote) that indicates which repositories have changed and need updating.

Since the for_each contains around 250 repositories; at least one of them always has a change. So it's practically impossible to change the script since one of those 250 repositories will have changed and hence the environment will have changed.

I have to keep 'state rm'-ing the relevant portions.

Can we lift this restriction?

@pennersm
Copy link

pennersm commented Mar 31, 2022

I am running into the same error with a almost identical config. It's a pitty, because if that would work, it'd be a really clean and native way to integrate a shell. E.g. to call ansible-playbook in an ENV that is feed from Terraform, very handy ....

resource "shell_script" "call_ansible" {
lifecycle_commands {
create = <<-EOF
cd "${path.module}/ansible/" && ansible-playbook -l ${path.module}/${var.ansible_playbook}
EOF
delete = "rm -f ${path.module}/${var.ansible_log}"
}
environment = {
ANSIBLE_PRIVATE_KEY_FILE = var.ansible_privkey
ANSIBLE_LOG_PATH = var.ansible_log
ANSIBLE_REMOTE_USER = var.ami_user
ANSIBLE_INVENTORY = var.ansible_hosts
}
depends_on = [local_file.ansible_inventory]
}

@TJM
Copy link

TJM commented Apr 21, 2023

There should at least be an option to override this. It is probably a decent restriction most of the time, but for me it just makes one MR turn into about 3-4.

@cveld
Copy link

cveld commented May 8, 2023

@scottwinkler there is a typo in this message follwed -> followed 😅

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

No branches or pull requests

5 participants