-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added organization level support to terraform spectrocloud module.
- Loading branch information
Showing
24 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/*module "fetcher_accounts" { | ||
source = "../modules/fetcher" | ||
rsubfolder = local.accounts_folder | ||
rprefix = "account-" | ||
}*/ | ||
|
||
locals { | ||
accounts_folder = "./" | ||
accounts_params = { ACCOUNT_DEV_NAME = "ehs-dev-030", ACCOUNT_PROD_NAME = "ehs-stg-004" } | ||
|
||
bsls_folder = "./" | ||
bsl_params = { BSL_NAME = "ehs-org-dev-storage-203" } | ||
|
||
profiles_folder = "./config/profile-2.0" | ||
profile_params = { | ||
SPECTRO_REPO_URL = "https://registry.spectrocloud.com", | ||
REPO_URL = "593235963820.dkr.ecr.us-west-2.amazonaws.com", | ||
|
||
OIDC_CLIENT_ID = "5ajs8pq0gatbgpjejld96fldrn", | ||
OIDC_ISSUER_URL = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_ajvPoziaS", | ||
|
||
RABBITMQ_PACK_VERSION = "8.15.2", | ||
|
||
string = "$${string}", | ||
|
||
ADDON_SPECTRO_REPO_URL = "https://addon-registry.gehc.spectrocloud.com", | ||
} | ||
|
||
projects_folder = "./config/project-2.0" | ||
projects_params = {} | ||
|
||
} | ||
|
||
module "SpectroOrg" { | ||
source = "../" | ||
sc_host = "api.dev.spectrocloud.com" #e.g: api.spectrocloud.com (for SaaS) | ||
sc_username = "[email protected]" #e.g: [email protected] | ||
sc_password = "welcome2Spectro1!" #e.g: supereSecure1! | ||
sc_project_name = "Default" #e.g: Default | ||
|
||
/*accounts = tomap({ | ||
for k, v in module.fetcher_accounts.object_files : | ||
k => yamldecode(templatefile(join("", [local.accounts_folder, "/${k}"]), local.accounts_params)) | ||
})*/ | ||
|
||
accounts = tomap({ | ||
for k, v in toset([ | ||
"config/account-2.0/account-aws-1.yaml", | ||
"config/account-2.0/account-aws-2.yaml", | ||
]) : | ||
k => yamldecode(templatefile(join("", [local.accounts_folder, "/${k}"]), local.accounts_params)) | ||
}) | ||
|
||
bsls = tomap({ | ||
for k, v in toset([ | ||
"config/bsl-2.0/bsl-s3-1.yaml", | ||
]) : | ||
k => yamldecode(templatefile(join("", [local.bsls_folder, "/${k}"]), local.bsl_params)) | ||
}) | ||
|
||
profiles = tomap({ | ||
for k, v in toset([ | ||
"profile-infra-EHS20RC1_Base_Infra_Org.yaml", | ||
"profile-addon-EHS20RC1_Pre-Reqs-Org.yaml", | ||
]) : | ||
k => yamldecode(templatefile(join("", [local.profiles_folder, "/${k}"]), local.profile_params)) | ||
}) | ||
|
||
projects = tomap({ | ||
for k, v in toset([ | ||
"project-developer-abc.yaml", | ||
"project-developer-arun.yaml", | ||
"project-developer-def.yaml", | ||
"project-providence-004.yaml" | ||
]) : | ||
k => yamldecode(templatefile(join("", [local.projects_folder, "/${k}"]), local.projects_params)) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
variable "sc_host" { | ||
description = "Spectro Cloud Endpoint" | ||
default = "api.spectrocloud.com" | ||
} | ||
|
||
variable "sc_username" { | ||
description = "Spectro Cloud Username" | ||
} | ||
|
||
variable "sc_password" { | ||
description = "Spectro Cloud Password" | ||
sensitive = true | ||
} | ||
|
||
variable "sc_project_name" { | ||
description = "Spectro Cloud Project (e.g: Default)" | ||
default = "Default" | ||
} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
username = var.sc_username | ||
password = var.sc_password | ||
project_name = var.sc_project_name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Spectro Cloud credentials | ||
sc_host = "{enter Spectro Cloud API endpoint}" #e.g: api.spectrocloud.com (for SaaS) | ||
sc_username = "{enter Spectro Cloud username}" #e.g: [email protected] | ||
sc_password = "{enter Spectro Cloud password}" #e.g: supereSecure1! | ||
sc_project_name = "{enter Spectro Cloud project Name}" #e.g: Default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Spectro Cloud credentials | ||
sc_host = "api.dev.spectrocloud.com" #e.g: api.spectrocloud.com (for SaaS) | ||
sc_username = "[email protected]" #e.g: [email protected] | ||
sc_password = "welcome2Spectro1!" #e.g: supereSecure1! | ||
sc_project_name = "Default" #e.g: Default | ||
|
||
# AWS Cloud Account credentials | ||
# Ensure minimum AWS account permissions: | ||
# https://docs.spectrocloud.com/clusters/?clusterType=aws_cluster#awscloudaccountpermissions | ||
aws_access_key = "AKIATD5NORWYBOSHBQE4" | ||
aws_secret_key = "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" | ||
|
||
# Existing SSH Key in AWS | ||
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html | ||
aws_ssh_key_name = "spectro2020" #e.g: default | ||
|
||
# Enter the AWS Region and AZ for cluster resources | ||
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions | ||
aws_region = "us-west-2" #e.g: us-west-2 | ||
aws_region_az = "us-west-2a" #e.g: us-west-2a | ||
|
||
cluster_files = ["./config/cluster-eks-test.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
variable "sc_host" { | ||
description = "Spectro Cloud Endpoint" | ||
default = "api.spectrocloud.com" | ||
} | ||
|
||
variable "sc_username" { | ||
description = "Spectro Cloud Username" | ||
} | ||
|
||
variable "sc_password" { | ||
description = "Spectro Cloud Password" | ||
sensitive = true | ||
} | ||
|
||
variable "sc_project_name" { | ||
description = "Spectro Cloud Project (e.g: Default)" | ||
default = "Default" | ||
} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
username = var.sc_username | ||
password = var.sc_password | ||
project_name = var.sc_project_name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
locals { | ||
|
||
fileset_root = "./"#join("", [path.module, "/"]) | ||
fileset_subfolder = join("", [local.fileset_root, var.rsubfolder]) | ||
|
||
param_files = fileset(local.fileset_subfolder, "param-*.yaml") | ||
params = { | ||
for k in local.param_files : | ||
trimsuffix(k, ".yaml") => yamldecode(file(join("", [var.rsubfolder, "/${k}"]))) | ||
} | ||
|
||
all_params = flatten( | ||
[ | ||
for k, v in local.params : v | ||
] | ||
) | ||
|
||
all_params_map = zipmap( | ||
flatten( | ||
[for item in local.all_params : keys(item)] | ||
), | ||
flatten( | ||
[for item in local.all_params : values(item)] | ||
) | ||
) | ||
|
||
object_files = fileset(local.fileset_subfolder, join("", [var.rprefix, "*.yaml"])) | ||
|
||
all_objects = tomap({ | ||
for k, v in local.object_files : k => yamldecode(templatefile(join("", [var.rsubfolder, "/${k}"]), local.all_params_map)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
output "all_objects" { | ||
value = local.all_objects | ||
} | ||
|
||
output "object_files" { | ||
value = local.object_files | ||
} | ||
|
||
output "all_files" { | ||
value = local.all_objects | ||
} | ||
|
||
output "all_params" { | ||
value = local.all_objects | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "rsubfolder" { | ||
type = string | ||
default = "config/profile-2.0" | ||
} | ||
|
||
variable "rprefix" { | ||
type = string | ||
default = "infra-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
locals { | ||
|
||
fileset_root = "./"#join("", [path.module, "/"]) | ||
fileset_subfolder = join("", [local.fileset_root, var.rsubfolder]) | ||
|
||
param_files = fileset(local.fileset_subfolder, "param-*.yaml") | ||
params = { | ||
for k in local.param_files : | ||
trimsuffix(k, ".yaml") => yamldecode(file(join("", [var.rsubfolder, "/${k}"]))) | ||
} | ||
|
||
all_params = flatten( | ||
[ | ||
for k, v in local.params : v | ||
] | ||
) | ||
|
||
all_params_map = zipmap( | ||
flatten( | ||
[for item in local.all_params : keys(item)] | ||
), | ||
flatten( | ||
[for item in local.all_params : values(item)] | ||
) | ||
) | ||
|
||
object_files = fileset(local.fileset_subfolder, join("", [var.rprefix, "*.yaml"])) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "object_files" { | ||
value = local.object_files | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "rsubfolder" { | ||
type = string | ||
default = "config/profile-2.0" | ||
} | ||
|
||
variable "rprefix" { | ||
type = string | ||
default = "infra-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
locals { | ||
all_objects_params_replaced = tomap({ | ||
for k, v in var.objects : k => yamldecode(templatefile(v, var.params)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "all_objects_params_replaced" { | ||
value = local.all_objects_params_replaced | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "objects" { | ||
type = list(any) | ||
default = [] | ||
} | ||
|
||
variable "params" { | ||
type = map | ||
default = {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "spectrocloud_cloudaccount_aws" "account" { | ||
for_each = var.accounts | ||
|
||
type = "sts" | ||
name = each.value.name | ||
arn = each.value.arn | ||
external_id = each.value.external_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
resource "spectrocloud_backup_storage_location" "bsl" { | ||
for_each = var.bsls | ||
|
||
name = each.value.name | ||
is_default = false | ||
region = each.value.region | ||
bucket_name = each.value.bucket_name | ||
s3 { | ||
credential_type = "sts" | ||
arn = each.value.arn | ||
external_id = each.value.external_id | ||
} | ||
} |
Oops, something went wrong.