Skip to content

Commit

Permalink
fixed provider and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aahel committed Aug 30, 2023
1 parent 9b2b9a5 commit cbe084d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ This example Terraform workspace will use the zip package to deploy the `consul-
add it to the `lambda-app-2` function so that it can call services within the Consul service mesh.

```shell
curl -o consul-lambda-extension.zip https://releases.hashicorp.com/consul-lambda-extension/${VERSION}/consul-lambda-extension_${VERSION}_linux_amd64.zip
curl -o consul-lambda-extension.zip "https://releases.hashicorp.com/consul-lambda-extension/${VERSION}-beta4/consul-lambda-extension_${VERSION}-beta4_linux_amd64.zip"
```

## Build the example Lambda function
Expand Down
2 changes: 1 addition & 1 deletion examples/lambda/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ variable "invocation_mode" {
default = "SYNCHRONOUS"
validation {
condition = contains(["SYNCHRONOUS", "ASYNCHRONOUS"], var.invocation_mode)
error_message = "invocation_mode must be one of SYNCHRONOUS or ASYNCHRONOUS"
error_message = "Invocation_mode must be one of SYNCHRONOUS or ASYNCHRONOUS."
}
}

Expand Down
15 changes: 0 additions & 15 deletions examples/lambda/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,10 @@ terraform {
version = "4.0.3"
}

docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}

provider "aws" {
region = var.region
}

# Equivalent of aws ecr get-login
data "aws_ecr_authorization_token" "ecr_auth" {}

provider "docker" {
host = "unix:///var/run/docker.sock" # Use the appropriate Docker socket for your system
registry_auth {
username = data.aws_ecr_authorization_token.ecr_auth.user_name
password = data.aws_ecr_authorization_token.ecr_auth.password
address = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com"
}
}
21 changes: 21 additions & 0 deletions modules/lambda-registrator/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}
locals {
on_vpc = length(var.subnet_ids) > 0 && length(var.security_group_ids) > 0
vpc_config = local.on_vpc ? [{
Expand All @@ -13,6 +22,18 @@ locals {
ecr_image_uri_pull-through = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/ecr-public/hashicorp/${var.private_repo_name}:${local.image_tag}"
}

# Equivalent of aws ecr get-login
data "aws_ecr_authorization_token" "ecr_auth" {}

provider "docker" {
host = "unix:///var/run/docker.sock" # Use the appropriate Docker socket for your system
registry_auth {
username = data.aws_ecr_authorization_token.ecr_auth.user_name
password = data.aws_ecr_authorization_token.ecr_auth.password
address = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com"
}
}

data "aws_caller_identity" "current" {}

resource "aws_iam_role" "registration" {
Expand Down

0 comments on commit cbe084d

Please sign in to comment.