خرید بک لینک

I’m new to Terraform and having problems setting up a very basic configuration. I want something that brings up my “docker-whale” image. From looking at Hashicorp and AWS docs, it seems I need an “aws_ecs_service” that uses a “aws_ecs_task_definition”.

Using this example, I’ve created the below config.

variable "access_key" {}
variable "secret_key" {}

provider "aws" {
  alias = "west"
  region = "us-west-1"
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
}

resource "aws_ecs_cluster" "default" {
  name = "whale"
}

resource "aws_ecs_service" "whale-service" {
  name            = "whale-service"
  cluster         = "${aws_ecs_cluster.default.id}"
  task_definition = "${aws_ecs_task_definition.whale-task.a}"
  desired_count   = 1
}

resource "aws_ecs_task_definition" "whale-task" {
  family = "whale"
  container_definitions = "${file("task-definitions/whale.json")}"
  volume {
    name = "whale-home"
    host_path = "/ecs/whale-home"
  }
}

Now, when I run terraform apply (access_key & secret_key redacted), everything seems to work fine. But I don’t see a corresponding ECS cluster or task definition in my AWS web console. Am I missing anything?

$ terraform apply 
provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Default: us-east-1
  Enter a value: 

aws_ecs_task_definition.whale-task: Refreshing state... (ID: whale)
aws_ecs_cluster.default: Creating...
  name: "" => "whale"
aws_ecs_cluster.default: Creation complete
aws_ecs_service.whale-service: Creating...
  cluster:                            "" => "a:aws:ecs:us-east-1:186598327969:cluster/whale"
  deployment_maximum_percent:         "" => "200"
  deployment_minimum_healthy_percent: "" => "100"
  desired_count:                      "" => "1"
  name:                               "" => "whale-service"
  task_definition:                    "" => "a:aws:ecs:us-east-1:186598327969:task-definition/whale:1"
aws_ecs_service.whale-service: Creation complete

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

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 23 فروردين 1395 ساعت: 3:06

صفحه بندی