To use iac describe, set up credentials to make authenticated requests to AWS. As you do for the AWS CLI, use credentials and configuration settings declared as user environment variables or in local AWS configuration files.
The iac describe command supports a named profile. By default, the CLI uses the settings found in the profile named default. You can override an individual setting by declaring the supported environment variables such as AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_PROFILE and so on.
If you are using an IAM role as an authorization tool, which is considered a good practice, you can still use iac describe by defining a profile for the role in your ~/.aws/config file.
[profile snykrole]
role_arn = arn:aws:iam::123456789012:role/<NAMEOFTHEROLE>
source_profile = user # profile to assume the role
region = eu-west-3
You can now use iac describe by overriding the profile setting.
$ AWS_PROFILE=snykrole snyk iac describe
Custom credentials to read a state on an S3 backend
If you want to use a different set of AWS credentials to read your state on S3, you can override each specific AWS environment variable with the DCTL_S3_ prefix. The purpose is to have the choice to read a state in a different region from your infrastructure. Remember to use your usual AWS credentials to read the resources of your actual infrastructure.
# Export a dedicated AWS named profile (or any other AWS environment variables) to read your state in your S3 backend
$ export DCTL_S3_PROFILE="s3reader"
# Export the usual AWS named profile
$ export AWS_PROFILE="snykrole"
$ snyk iac describe --from="tfstate+s3://mybucket/terraform.tfstate"
# You can also use a specific region to authenticate to the S3 bucket
$ DCTL_S3_REGION=us-east-1 snyk iac describe --from="tfstate+s3://mybucket/terraform.tfstate"
Terraform custom role
The following code represents the custom role you can assume to run iac describe written in HCL.
Deploy this CloudFormation template to create the limited permission role that you can use according to the authentication guide in the preceding sections of this page.
When the stack is deployed, attach the following policy to your IAM user. This allows the user to assume only the role specified. For more information about granting a user access to assume a role, see the AWS Identity and Access Management User Guide.
There is no automatic way to update the CloudFormation template from the Snyk side because you launched this template from your AWS account. Therefore you must update the template yourself to use the most recent Snyk role.
Update the CloudFormation template using the AWS console
Select Replace current template and specify the Snyk Amazon S3 URLhttps://driftctl-cfn-templates.s3.eu-west-3.amazonaws.com/driftctl-role.yml; click Next.
On the Specify stack details and the Configure stack options pages, click Next.
In the Change set preview section, check that AWS CloudFormation will make the changes.
Because the Snyk template contains one IAM resource, select I acknowledge that this template may create IAM resources.
To finish, click Update stack.
Update the CloudFormation template using the AWS CLI