简体   繁体   English

如何将terraform与atlassian / localstack集成?

[英]How to integrate terraform with atlassian/localstack?

Terraform can be configured with custom S3 endpoints and it seems that localstack can create local stacks for S3, SES, Cloudformation and few others services. Terraform可以配置自定义S3端点 ,似乎localstack可以为S3,SES,Cloudformation和其他少数服务创建本地堆栈。

The question is what to write in Terraform configuration to use localstack's S3 endpoint? 问题是在Terraform配置中写什么来使用localstack的S3端点?

Terraform does not officially support "AWS-workalike" systems, since they often have subtle quirks and differences relative to AWS itself. Terraform并未正式支持“AWS-workalike”系统,因为它们通常与AWS本身存在微妙的怪癖和差异。 However, it is supported on a best-effort basis and may work if localstack is able to provide a sufficiently realistic impression of S3 for Terraform's purposes. 但是,它是尽力支持的,如果localstack能够为Terraform的目的提供足够逼真的S3印象,则可能会有效。

According to the localstack docs, by default the S3 API is exposed at http://localhost:4572 , so setting the custom endpoint this way may work: 根据localstack文档,默认情况下,S3 API在http://localhost:4572公开,因此以这种方式设置自定义端点可能有效:

provider "aws" {
  endpoints {
    s3 = "http://localhost:4572"
  }
}

Depending on the capabilities of localstack, you may need to set some other settings: 根据localstack的功能,您可能需要设置一些其他设置:

  • s3_force_path_style to use a path-based addressing scheme for buckets and objects. s3_force_path_style为存储桶和对象使用基于路径的寻址方案。
  • skip_credentials_validation , since localstack seems to lack an implementation of the AWS token service. skip_credentials_validation ,因为localstack似乎缺少AWS令牌服务的实现。
  • skip_metadata_api_check if IAM-style credentials will not be used, to prevent Terraform from trying to get credentials from the EC2 metadata API. skip_metadata_api_check如果不使用IAM样式的凭据,则阻止Terraform尝试从EC2元数据API获取凭据。

Building off @martin-atkins' answer, here's a sample Terraform file that works with Localstack: 建立@ martin-atkins的答案,这是一个与Localstack一起使用的示例Terraform文件:

provider "aws" {
  region = "us-east-1"
  access_key = "anaccesskey"
  secret_key = "asecretkey"
  skip_credentials_validation = true
  skip_metadata_api_check = true
  s3_force_path_style = true
  endpoints {
    s3 = "http://localhost:4572"
  }
}

resource "aws_s3_bucket" "b" {
  bucket = "my-tf-test-bucket"
  acl    = "public-read"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM