AWS - Does Terraform Init Task Support DynamoDB Backend for Locking with S3 State Files?
If you want to use DynamoDB in collaboration with S3 to handle locking and state checksum management, can you do that with the TerraformCLI@0 init task? I searched around the repo, but I didn't have any luck figuring out whether this would be supported with something like "dynamo_db_table: states.locks."
displayName: 'terraform init'
inputs:
command: init
workingDirectory: $(my_terraform_templates_dir)
# set to `aws` to use aws backend
backendType: aws
# service connection name, required if backendType = aws
backendServiceAws: env_test_aws
# s3 bucket's region, optional if provided elsewhere (i.e. inside terraform template or command options)
backendAwsRegion: us-east-1
# s3 bucket name, optional if provided elsewhere (i.e. inside terraform template or command options)
backendAwsBucket: s3-trfrm-dev-eus-czp
# s3 path to state file, optional if provided elsewhere (i.e. inside terraform template or command options)
backendAwsKey: 'my-env-infrax/dev-infrax'```
@piizei do you have any insights here?
From what I see from the source code the parameter is not managed, but you can add the relevant options using -backend-config=key=value in commandOptions
Eg:
- task: TerraformCLI@0
displayName: 'terraform init'
inputs:
command: init
workingDirectory: $(my_terraform_templates_dir)
backendType: aws
backendServiceAws: env_test_aws
backendAwsRegion: us-east-1
backendAwsBucket: s3-trfrm-dev-eus-czp
backendAwsKey: 'my-env-infrax/dev-infrax'
commandOptions: '-backend-config=dynamodb_table=lock_table'
Hi, I am struggling a bit to store state file in S3 backend though using similar options, just want to confirm if code above does allow Apply task to add stattefile in S3?