首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用terraform在EC2上创建LocalStack实例?

如何使用terraform在EC2上创建LocalStack实例?
EN

Stack Overflow用户
提问于 2020-04-07 15:49:13
回答 1查看 8.1K关注 0票数 4

我正在尝试使用Terraform在LocalStack上运行LocalStack实例。

在尝试创建实例50分钟之后,我从terraform获得了这个响应:

错误:获取EC2实例(i-cf4da152ddf3500e1)的错误: SerializationError:未能解除封送错误消息状态代码: 500,请求id:引起: UnmarshalError:未能解除由:预期元素类型引起的错误消息,但有

在main.tf第34行中,在资源"aws_instance“”示例“中: 34:资源"aws_instance”示例“{

对于LocalStack和Terraformv0.12.18,我使用以下配置:

代码语言:javascript
运行
复制
provider "aws" {
  access_key                  = "mock_access_key"
  region                      = "us-east-1"
  s3_force_path_style         = true
  secret_key                  = "mock_secret_key"
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    apigateway     = "http://localhost:4567"
    cloudformation = "http://localhost:4581"
    cloudwatch     = "http://localhost:4582"
    dynamodb       = "http://localhost:4569"
    es             = "http://localhost:4578"
    firehose       = "http://localhost:4573"
    iam            = "http://localhost:4593"
    kinesis        = "http://localhost:4568"
    lambda         = "http://localhost:4574"
    route53        = "http://localhost:4580"
    redshift       = "http://localhost:4577"
    s3             = "http://localhost:4572"
    secretsmanager = "http://localhost:4584"
    ses            = "http://localhost:4579"
    sns            = "http://localhost:4575"
    sqs            = "http://localhost:4576"
    ssm            = "http://localhost:4583"
    stepfunctions  = "http://localhost:4585"
    sts            = "http://localhost:4592"
    ec2            = "http://localhost:4597"
  }
}

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

当我从最新的github (https://github.com/localstack/localstack)日志中直接从最新的github(https://github.com/localstack/localstack)中运行EC2时,我已经看到了EC2相关端点的设置。

我很感激任何能帮助我在LocalStack上运行LocalStack的建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-19 06:32:25

良好的工作下面的码头形象的地方堆栈。

码头运行-it -p 4500-4600:4500-4600 -p 8080:8080 -暴露4572个地区堆栈/地区堆栈:0.11.1

代码语言:javascript
运行
复制
resource "aws_instance" "web" {
  ami           = "ami-0d57c0143330e1fa7"
  instance_type = "t2.micro"

  tags = {
    Name = "HelloWorld"
  }
}

provider "aws" {
  region                      = "us-east-1"
  s3_force_path_style         = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    apigateway     = "http://localhost:4567"
    cloudformation = "http://localhost:4581"
    cloudwatch     = "http://localhost:4582"
    dynamodb       = "http://localhost:4569"
    es             = "http://localhost:4578"
    firehose       = "http://localhost:4573"
    iam            = "http://localhost:4593"
    kinesis        = "http://localhost:4568"
    lambda         = "http://localhost:4574"
    route53        = "http://localhost:4580"
    redshift       = "http://LOCALHOST:4577"
    s3             = "http://localhost:4572"
    secretsmanager = "http://localhost:4584"
    ses            = "http://localhost:4579"
    sns            = "http://localhost:4575"
    sqs            = "http://localhost:4576"
    ssm            = "http://localhost:4583"
    stepfunctions  = "http://localhost:4585"
    sts            = "http://localhost:4592"
    ec2            = "http://localhost:4597"

  }
}

terraform应用

代码语言:javascript
运行
复制
aws_instance.web: Destroying... [id=i-099392def6b574255]
aws_instance.web: Still destroying... [id=i-099392def6b574255, 10s elapsed]
aws_instance.web: Destruction complete after 10s
aws_instance.web: Creating...
aws_instance.web: Still creating... [10s elapsed]
aws_instance.web: Creation complete after 12s [id=i-9c942d138970d44a4]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

注意事项:它是一个虚拟实例,因此对于ssh和所有这些都是不可用的。然而,适合于在ec2上测试地形应用/破坏用例。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61084050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档