- Newest
- Most votes
- Most comments
The error you're encountering is due to running the local-exec provisioner on a Windows system. The command in the provisioner is using Unix/Linux syntax, which is not compatible with Windows PowerShell. To resolve this issue, you need to modify the local-exec provisioner to use Windows-compatible commands. Here's how you can adjust it:
-
Replace 'sleep' with 'Start-Sleep': Windows doesn't have a 'sleep' command, but PowerShell has 'Start-Sleep'.
-
Use PowerShell's line continuation character (backtick `) instead of the Unix-style backslash ().
-
Specify PowerShell as the interpreter.
Here's an adjusted version of the local-exec provisioner that should work on Windows:
provisioner "local-exec" { interpreter = ["PowerShell", "-Command"] command = <<-COMMAND Start-Sleep -Seconds 100 aws cognito-idp update-user-pool-client ` --user-pool-id ${aws_cognito_user_pool.aos_pool.id} ` --client-id ${aws_cognito_user_pool_client.aos_user_pool_client.id} ` --supported-identity-providers "COGNITO" ` --callback-urls "https://${self.kibana_endpoint}app/kibana" ` --logout-urls "https://${self.kibana_endpoint}app/kibana" ` --allowed-o-auth-flows "code" ` --allowed-o-auth-scopes "email" "openid" ` --allowed-o-auth-flows-user-pool-client ` --region ${local.aws_region} COMMAND }
This modification should allow the local-exec provisioner to run successfully on your Windows system. The 'Start-Sleep -Seconds 100' command will pause the execution for 100 seconds, giving time for the endpoint to become available before running the AWS CLI command.
Make sure you have the AWS CLI installed and configured on your Windows system, as the command relies on it to update the Cognito user pool client.
If you continue to face issues, you might want to consider using a more cross-platform approach, such as writing a small script (e.g., Python) that can run on both Windows and Linux, and calling that script from your Terraform configuration.
Sources
AWS Credentials Issues in Terraform | AWS re:Post
OpenSearchService: New-OSDomain Cmdlet | AWS Tools for PowerShell
Relevant content
- asked 10 months ago