microsoft-terraform-test docker image 镜像
source link: https://hub.docker.com/r/microsoft-terraform-test
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
docker pull microsoft-terraform-test
# Featured Tags
latest
docker pull mcr.microsoft.com/terraform-test
About This Image
This Docker image (see Dockerfile) is for testing Azure Terraform modules.
Terraform 0.12
This image now supports terraform 0.12.
How to Use This Image
This image can be used for terraform lint or end to end tests against Azure.
Lint Tests
These tests ensure consistency in formatting for the terraform module code.
Setup the environment variable which specifies the root path of the module code on the local machine.
export MODULE_PATH=/user/me/source/Azure/terraform-azurerm-modulename
Now run the lint tests:
docker run -v $MODULE_PATH:/tf-test/module --rm microsoft/terraform-test rake -f ../Rakefile build
End to End Tests
These tests will execute a terraform apply
to deploy the azure module as defined in the /test/integration
directory and then terraform destroy
to delete them.
Configuration
Azure Setup The container uses Azure SPN Keys to access Azure. The following environment variables need to be set on the local machine running the container image.
ARM_SUBSCRIPTION_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ARM_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ARM_CLIENT_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ARM_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ARM_TEST_LOCATION=westus
ARM_TEST_LOCATION_ALT=westus
Log Setup
The logs generated by the test will be stored in the /tf-test/.kitchen
directory in the container. Mount this directory to the location of your choice so you can keep the logs once the test have completed.
Secret Setup
Some test may require SSH keys or other secrets to be passed to the container. For SSH keys, mount the directory where they are located as /root/.ssh
in the container. If you are reusing your keys, the above command should be:
Running the Tests
Setup the environment variable which specifies the root path of the module code on the local machine.
export MODULE_PATH=/user/me/source/Azure/terraform-azurerm-modulename
Now run the tests using this docker command:
docker run -v ~/.ssh:/root/.ssh/ -v $MODULE_PATH/logs:/tf-test/module/.kitchen -v $MODULE_PATH:/tf-test/module -e ARM_CLIENT_ID -e ARM_TENANT_ID -e ARM_SUBSCRIPTION_ID -e ARM_CLIENT_SECRET -e ARM_TEST_LOCATION -e ARM_TEST_LOCATION_ALT --rm microsoft/terraform-test rake -f ../Rakefile e2e
This may take a number of minutes depending on the size of the module and there will be no output to the terminal until the tests complete. To see progress, look at the files being generated and updated under the local $MODULE_PATH/logs
directory.
Full Tag Listing
You can retrieve a list of all available tags for terraform-test at https://mcr.microsoft.com/v2/terraform-test/tags/list
Support
If you encounter any bugs with the tool, please file an issue in GitHub.
License
- Legal Notice: Container License Information
See license terms here.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK