Terratest 仍是我们感兴趣的基础设施测试工具。 它是一个 Golang 库,用来简化基础设施代码的自动化测试编写。通过基础设施即代码的工具,例如 Terraform,你可以创建真实的基础设施组件(如服务器、防火墙或负载均衡器),在它们之上部署应用程序,并使用 Terratest 验证预期的行为。在测试结束后,Terratest 可以取消应用的部署并清理资源。 我们的团队们认为这种测试基础设施组件的方式有助于提供对基础设施即代码的自信。我们看到我们的团队们对应用组件和它们之间的集成编写了各种基础设施安全测试,包括检查错误配置,验证访问权限(比如检查特定 IAM 角色和权限是否被正确配置),检查对敏感资源的未认证访问的网络安全测试等这使得安全测试左移并在开发过程中提供反馈成为可能。
We widely use Terraform as code to configure a cloud infrastructure. Terratest is a Golang library that makes it easier to write automated tests for infrastructure code. A test run creates real infrastructure components (such as servers, firewalls or load balancers), deploys applications on them and validates the expected behavior using Terratest. At the end of the test, Terratest can undeploy the apps and clean up resources. This makes it largely useful for end-to-end tests of your infrastructure in a real environment.