Skip to content

Commit

Permalink
moved providers to examples/lambda providers.tf
Browse files Browse the repository at this point in the history
  • Loading branch information
aahel committed Aug 30, 2023
1 parent 88af71f commit 9b2b9a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
17 changes: 17 additions & 0 deletions examples/lambda/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ terraform {
source = "hashicorp/tls"
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"
}
}
29 changes: 0 additions & 29 deletions modules/lambda-registrator/main.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

locals {
on_vpc = length(var.subnet_ids) > 0 && length(var.security_group_ids) > 0
vpc_config = local.on_vpc ? [{
Expand All @@ -29,9 +15,6 @@ locals {

data "aws_caller_identity" "current" {}

provider "aws" {
region = var.region
}
resource "aws_iam_role" "registration" {
name = var.name

Expand Down Expand Up @@ -154,18 +137,6 @@ resource "aws_ecr_repository" "lambda-registrator" {
force_delete = true
}

# 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"
}
}


resource "aws_ecr_pull_through_cache_rule" "pull_through_cache_rule" {
count = var.pull_through ? 1 : 0
Expand Down

0 comments on commit 9b2b9a5

Please sign in to comment.