Skip to content

Commit

Permalink
Adding test case showing modules that are embedded within other modul…
Browse files Browse the repository at this point in the history
…es that cause the issue
  • Loading branch information
salexpdx committed Oct 30, 2020
1 parent 89b06f6 commit 68c7601
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "m1projectid" {
type = string
default = "asdfasdf"
}

module "m2" {
source = "../m2"
m2versionyear = "2012"
m2versionmonth = "10"
m2versionday = "17"
m2bucketname = module.m3.fullbucketname
}
module "m3" {
source = "../m3"
m3bucketname = var.m1projectid
m3environment = "dev"
}


resource "aws_s3_bucket" "bucket" {
bucket = module.m3.fullbucketname
policy = module.m2.fullbucketpolicy
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
variable "m2versionyear" {
type = string
}
variable "m2versionmonth" {
type = string
}
variable "m2versionday" {
type = string
}
variable "m2bucketname" {
type = string
}
data "aws_iam_policy_document" "readbuckets" {
source_json = <<EOF
{
"Version":"${var.m2versionyear}-${var.m2versionmonth}-${var.m2versionday}",
"Statement":[
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::${var.m2bucketname}/*"]
}
]
}
EOF
}

output "fullbucketpolicy" {
value = data.aws_iam_policy_document.readbuckets.json
}
output "BucketARN" {
value = var.m2bucketname
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "m3bucketname" {
type = string
}
variable "m3environment" {
type = string
}

output "fullbucketname" {
value = "${var.m3bucketname}-${var.m3environment}"
}
output "sourcebucketname" {
value = var.m3bucketname
}
output "sourceenvironment" {
value = var.m3environment
}

15 changes: 15 additions & 0 deletions pkg/iac-providers/terraform/v12/testdata/deep-modules/template.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_version = ">= 0.12.0"
}

provider "aws" {
version = "2.58.0"
region = "us-east-1"
}


module "m1" {
source = "./modules/m1"
m1projectid = "tf-test-project"
}

0 comments on commit 68c7601

Please sign in to comment.