Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTMDB-19: Added resource and datasource(s) of data lake #414

Merged
merged 18 commits into from
Jun 12, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/atlas-dataLake-roles/aws-roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id

policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
EOF
}

resource "aws_iam_role" "test_role" {
name = "test_role"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}"
}
}
}
]
}
EOF

}
43 changes: 43 additions & 0 deletions examples/atlas-dataLake-roles/import/aws-roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = aws_iam_role.test_role.id

policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
EOF
}

resource "aws_iam_role" "test_role" {
name = "test_role"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}"
}
}
}
]
}
EOF

}

30 changes: 30 additions & 0 deletions examples/atlas-dataLake-roles/import/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}


resource "mongodbatlas_cloud_provider_access_setup" "setup_only" {
project_id = mongodbatlas_project.test.id
provider_name = "AWS"
}

resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {
project_id = mongodbatlas_project.test.id
role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id

aws = {
iam_assumed_role_arn = aws_iam_role.test_role.arn
}
}

resource "mongodbatlas_data_lake" "test" {
project_id = mongodbatlas_project.test.id
name = var.data_lake_name
aws_role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
aws_test_s3_bucket = var.test_s3_bucket
data_process_region = {
cloud_provider = "AWS"
region = var.data_lake_region
}
}
10 changes: 10 additions & 0 deletions examples/atlas-dataLake-roles/import/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
provider "mongodbatlas" {
public_key = var.public_key
private_key = var.private_key
andreaangiolillo marked this conversation as resolved.
Show resolved Hide resolved
base_url = var.base_url
}
provider "aws" {
access_key = var.access_key
secret_key = var.secret_key
region = var.aws_region
}
56 changes: 56 additions & 0 deletions examples/atlas-dataLake-roles/import/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
variable "public_key" {
andreaangiolillo marked this conversation as resolved.
Show resolved Hide resolved
description = "The public API key for MongoDB Atlas"
default = ""
}
variable "private_key" {
description = "The private API key for MongoDB Atlas"
default = ""
}
variable base_url {
type = string
default = ""
}
variable "project_name" {
description = "Atlas project name"
default = ""
}
variable "org_id" {
description = "Atlas organization id"
default = ""
}
variable "access_key" {
description = "The access key for AWS Account"
default = ""
}
variable "secret_key" {
description = "The secret key for AWS Account"
default = ""
}
variable "customer_master_key" {
description = "The customer master secret key for AWS Account"
default = ""
}
variable "atlas_region" {
default = "US_EAST_1"
description = "Atlas Region"
}
variable "aws_region" {
default = "us-east-1"
description = "AWS Region"
}
variable "aws_iam_role_arn" {
description = "AWS IAM ROLE ARN"
default = ""
}
variable "test_s3_bucket" {
description = "The name of s3 bucket"
default = ""
}
variable "data_lake_name" {
description = "The data lake name"
default = ""
}
variable "data_lake_region" {
default = "VIRGINIA_USA"
description = "The data lake region"
}
12 changes: 12 additions & 0 deletions examples/atlas-dataLake-roles/import/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.1.0-dev"
}
}
required_version = ">= 0.15"
}
50 changes: 50 additions & 0 deletions examples/atlas-dataLake-roles/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
resource "mongodbatlas_project" "test" {
name = var.project_name
org_id = var.org_id
}


resource "mongodbatlas_cloud_provider_access_setup" "setup_only" {
project_id = mongodbatlas_project.test.id
provider_name = "AWS"
}

resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {
project_id = mongodbatlas_project.test.id
role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id

aws = {
iam_assumed_role_arn = aws_iam_role.test_role.arn
}
}

resource "mongodbatlas_data_lake" "test" {
project_id = mongodbatlas_project.test.id
name = var.data_lake_name
aws_role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
aws_test_s3_bucket = var.test_s3_bucket
data_process_region = {
cloud_provider = "AWS"
region = var.data_lake_region
}
}


output "project_id" {
andreaangiolillo marked this conversation as resolved.
Show resolved Hide resolved
value = mongodbatlas_project.test.id
}
output "role_id" {
value = mongodbatlas_cloud_provider_access_setup.setup_only.role_id
}
output "role_name" {
value = aws_iam_role.test_role.name
}
output "policy_name" {
value = aws_iam_role_policy.test_policy.name
}
output "data_lake_name" {
value = mongodbatlas_data_lake.test.name
}
output "s3_bucket" {
value = mongodbatlas_data_lake.test.aws_test_s3_bucket
}
10 changes: 10 additions & 0 deletions examples/atlas-dataLake-roles/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
provider "mongodbatlas" {
public_key = var.public_key
private_key = var.private_key
base_url = var.base_url
}
provider "aws" {
access_key = var.access_key
secret_key = var.secret_key
region = var.aws_region
}
57 changes: 57 additions & 0 deletions examples/atlas-dataLake-roles/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
variable "public_key" {
description = "The public API key for MongoDB Atlas"
default = ""
}
variable "private_key" {
description = "The private API key for MongoDB Atlas"
default = ""
}
variable base_url {
type = string
default = ""
}

variable "project_name" {
description = "Atlas project name"
default = ""
}
variable "org_id" {
description = "Atlas organization id"
default = ""
}
variable "access_key" {
description = "The access key for AWS Account"
default = ""
}
variable "secret_key" {
description = "The secret key for AWS Account"
default = ""
}
variable "customer_master_key" {
description = "The customer master secret key for AWS Account"
default = ""
}
variable "atlas_region" {
default = "US_EAST_1"
description = "Atlas Region"
}
variable "aws_region" {
default = "us-east-1"
description = "AWS Region"
}
variable "aws_iam_role_arn" {
description = "AWS IAM ROLE ARN"
default = ""
}
variable "test_s3_bucket" {
description = "The name of s3 bucket"
default = ""
}
variable "data_lake_name" {
description = "The data lake name"
default = ""
}
variable "data_lake_region" {
default = "VIRGINIA_USA"
description = "The data lake region"
}
12 changes: 12 additions & 0 deletions examples/atlas-dataLake-roles/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
mongodbatlas = {
source = "mongodb/mongodbatlas"
version = "0.1.0-dev"
}
}
required_version = ">= 0.15"
}
Loading