您可以将Google云模拟器与Terraform一起使用吗?
当我正确设置仿真器和Terraform时,我是否可以在模拟器内而不是在Google Cloud中的项目中运行Terraform?
我找不到网络上的答案,在我知道之前无法开始。
提前致谢!
When I setup the emulator and Terraform correctly, will I be able to run terraform with the results inside the emulator and not inside my project in Google Cloud?
I could not find an answer on the web and cannot start before I know.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,你可以!我们使用它来通过重复现有的生产环境配置来引导Google Pubsub仿真器。
诀窍是您需要覆盖提供商配置中的API端点:
为了应用此操作,我以下启动模拟器:
注意:
缺点
启动,因为您仅覆盖特定的端点,因此必须小心您创建的资源。例如,创建一个
Google_service_account
将发送将请求发送到实际的Google端点。有一些 Google服务的模拟器,但不是全部!另外,您可以覆盖Terraform提供商中的所有端点,以使其不存在本地端口。然后,这将无法应用计划,而不是在您可能不会期望的PREM上默默创建资源。
Yes you can! We use it to bootstrap the Google PubSub emulator by reusing our existing production environment configuration.
The trick is that you need to override the API Endpoints in the provider configuration:
To apply this then, I start the emulator like this:
Note:
Drawbacks
Since you're overriding only specific endpoint, you must be careful which resources you create. For example, creating a
google_service_account
will sent that request to the actual Google endpoint.There are emulators for some Google service, but not all! Alternatively, you can override all endpoints in the Terraform Provider to non-existing local ports. This will then fail to apply the plan instead of silently creating resources on prem that you might not expect.
似乎用户想使用Terraform并将其指向仿真器。
https://cloud.google.com/spanner/docs/docs/emulator
请纠正我如果我错了。
It seems user want to play with terraform and point it to the emulator.
https://cloud.google.com/spanner/docs/emulator
Please correct me if I'm wrong.