terraform-cdk
terraform-cdk copied to clipboard
Issue with @cdktf/provider-postgresql Grant (Add terraform-parallelism flag)
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
cdktf & Language Versions
"@cdktf/provider-aws": "^7.0.13" "@cdktf/provider-postgresql": "^0.4.12" "@cdktf/provider-random": "^0.2.12" "cdktf": "^0.10"
"ts-node": "^10.7.0", "typescript": "^4.6.2"
Affected Resource(s)
PostgresqlProvider Grant Resource
Debug Output
Error: could not execute revoke query: pq: tuple concurrently updated
Expected Behavior
Successfully created each role grant for each role.
Actual Behavior
Concurrency error in spite of trying both the --parallelism=0
and --parallelism=1
flags
Steps to Reproduce
roles.forEach((role) => {
...doStuff
role.grants.forEach((grant) => {
new Grant(this, `${this.deploymentPrefix}-${role.name}-${grant.objectType}-grant`, {
role: role.name,
database: role.database,
objectType: grant.objectType,
privileges: grant.privileges,
});
});
})
Important Factoids
I've done some research and tried the concurrency flag which doesn't seem to be fixing anything. My assumption is that either something is wrong with the flag implementation in CDKTF or the Grant object itself.
You could try setting an environment variable as described here. cdktf doesn't currently support passing flags to Terraform, but you can also run Terraform directly from the stack output directory.
This PR added a parallelism
flag to the cdktf-cli, however that one addresses deploying multiple stacks in parallel and does not show the same behaviour as the parallelism
flag of the Terraform CLI. To me it would make sense to e.g. expose a --terraform-parallelism
flag or similar to allow setting this flag, when required as a workaround for underlying provider issues.
Thanks @jsteinich that worked for me. For anyone referencing this do:
TF_CLI_ARGS_apply="-parallelism=1" cdktf deploy <stack name>
@ansgarm having a direct flag like that would definitely be nice though
#734 is asking for the same flag.
Thanks @jsteinich that worked for me. For anyone referencing this do:
TF_CLI_ARGS_apply="-parallelism=1" cdktf deploy <stack name>
@ansgarm having a direct flag like that would definitely be nice though
cdktf command, Don't take effect
Hi @jaty613, could you explain a bit more what you did that did not work? Which command did you try? What operating system are you using?
Hi @jaty613, could you explain a bit more what you did that did not work? Which command did you try? What operating system are you using?
env: Terraform v1.1.7 on windows_386
terraform apply --auto-approve (parallelism parameters to take effect)
cdktf deploy
Hi @jaty613, where do you set those environment variables? Are you using an IDE, a terminal (which one?) or something else?
What do you do to confirm that parallelism
does not take effect? Terraform will only run things in parallel that have no dependencies onto each other – maybe that's what you are experiencing? Could you share your CLI output in a Github Gist or send us an reproduction case?
Hi @jaty613, where do you set those environment variables? Are you using an IDE, a terminal (which one?) or something else? What do you do to confirm that
parallelism
does not take effect? Terraform will only run things in parallel that have no dependencies onto each other – maybe that's what you are experiencing? Could you share your CLI output in a Github Gist or send us an reproduction case?
In the Windows operating system, set the environment variables as system environment variables and ensure that the environment variables take effect。
@jaty613 What terminal application are you using on windows?
@jaty613 What terminal application are you using on windows? cmd & powshell
What does running echo %TF_CLI_ARGS_apply%
return?
C:\Users\root>echo %TF_CLI_ARGS_apply% -parallelism=800
C:\Users\root>echo %TF_CLI_ARGS_apply% -parallelism=800
The actual maximum number of parallelism runs is the default value of 10
You mentioned Powershell. Is it correctly returning the -parallelism=800
in the Powershell as well?
How many resources do you apply (of which only 10 apply in parallel)?
You mentioned Powershell. Is it correctly returning the
-parallelism=800
in the Powershell as well? How many resources do you apply (of which only 10 apply in parallel)?
PS C:\Users\root> $env:TF_CLI_ARGS_apply -parallelism=800
One stack has 200 resources
The terraform apply command parallelizes the maximum number of resources, but the CDKTF deploy command does not
Could you try setting the CDKTF_LOG_LEVEL
environment variable and see if that has an effect (it should create more output logging while running e.g. deploy or diff).
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.