From 0d588037ecdbf7ca173f0ab2612e0cc4fca5eb85 Mon Sep 17 00:00:00 2001 From: Nikolay Date: Thu, 7 Oct 2021 01:01:40 -0700 Subject: [PATCH] Fixing examples integration. --- examples/config/cluster/cluster-eks-dev.yaml | 2 +- examples/config/profile/profile-addon-1.yaml | 4 +-- examples/mod_spectro_org.tf | 25 +++++---------- examples/modules/fetch_replace/main.tf | 32 -------------------- examples/modules/fetch_replace/output.tf | 15 --------- examples/modules/fetch_replace/variables.tf | 9 ------ examples/modules/fetcher/main.tf | 28 ----------------- examples/modules/fetcher/output.tf | 3 -- examples/modules/fetcher/variables.tf | 9 ------ examples/modules/replacer/main.tf | 5 --- examples/modules/replacer/output.tf | 3 -- examples/modules/replacer/variables.tf | 9 ------ examples/providers.tf | 2 +- main.tf | 2 +- spectro-aws-account.tf | 4 +++ spectro-profile.tf | 6 +++- spectro-s3-sts-backup.tf | 4 +++ variables.tf | 1 - 18 files changed, 25 insertions(+), 138 deletions(-) delete mode 100644 examples/modules/fetch_replace/main.tf delete mode 100644 examples/modules/fetch_replace/output.tf delete mode 100644 examples/modules/fetch_replace/variables.tf delete mode 100644 examples/modules/fetcher/main.tf delete mode 100644 examples/modules/fetcher/output.tf delete mode 100644 examples/modules/fetcher/variables.tf delete mode 100644 examples/modules/replacer/main.tf delete mode 100644 examples/modules/replacer/output.tf delete mode 100644 examples/modules/replacer/variables.tf diff --git a/examples/config/cluster/cluster-eks-dev.yaml b/examples/config/cluster/cluster-eks-dev.yaml index 5b79648..bd1ca88 100644 --- a/examples/config/cluster/cluster-eks-dev.yaml +++ b/examples/config/cluster/cluster-eks-dev.yaml @@ -2,7 +2,7 @@ name: eks-dev cloud_account: dev-030 profiles: infra: - name: EKS-Base + name: profile_infra packs: - name: kubernetes-eks version: "1.20" diff --git a/examples/config/profile/profile-addon-1.yaml b/examples/config/profile/profile-addon-1.yaml index 63751d3..747cc4d 100644 --- a/examples/config/profile/profile-addon-1.yaml +++ b/examples/config/profile/profile-addon-1.yaml @@ -1,5 +1,5 @@ -name: profile_addon -description: profile_addon +name: addon-profile-1 +description: addon-profile-1 type: add-on defaultRepoURL: "${REPO_URL}" diff --git a/examples/mod_spectro_org.tf b/examples/mod_spectro_org.tf index 74c428b..6b84170 100644 --- a/examples/mod_spectro_org.tf +++ b/examples/mod_spectro_org.tf @@ -1,11 +1,5 @@ -/*module "fetcher_accounts" { - source = "./modules/fetcher" - rsubfolder = local.accounts_folder - rprefix = "account-" -}*/ - locals { - accounts_params = { ACCOUNT_DEV_NAME = "ehs-dev-030", ACCOUNT_PROD_NAME = "ehs-stg-004" } + accounts_params = { ACCOUNT_DEV_NAME = "dev-030", ACCOUNT_PROD_NAME = "ehs-stg-004" } bsl_params = { BSL_NAME = "qa-sharma" } @@ -30,17 +24,12 @@ locals { } module "SpectroOrg" { - source = "../" - sc_host = "api.stage.spectrocloud.com" #e.g: api.spectrocloud.com (for SaaS) - sc_username = "nikolay+demo@spectrocloud.com" #e.g: user1@abc.com - sc_password = "welcome2Spectr0!1" #e.g: supereSecure1! + source = "github.com/spectrocloud/terraform-spectrocloud-modules" + sc_host = "" #e.g: api.spectrocloud.com (for SaaS) + sc_username = "" #e.g: user1@abc.com + sc_password = "" #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 = { for k in fileset("config/account", "account-*.yaml") : trimsuffix(k, ".yaml") => yamldecode(templatefile("config/account/${k}", local.accounts_params)) @@ -67,7 +56,7 @@ module "SpectroOrg" { } clusters = { - for k in fileset("config/cluster", "team-*.yaml") : - trimsuffix(k, ".yaml") => yamldecode(templatefile("config/project/${k}", {})) + for k in fileset("config/cluster", "cluster-eks-*.yaml") : + trimsuffix(k, ".yaml") => yamldecode(file("config/cluster/${k}")) } } \ No newline at end of file diff --git a/examples/modules/fetch_replace/main.tf b/examples/modules/fetch_replace/main.tf deleted file mode 100644 index 783bbd7..0000000 --- a/examples/modules/fetch_replace/main.tf +++ /dev/null @@ -1,32 +0,0 @@ -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)) - }) -} \ No newline at end of file diff --git a/examples/modules/fetch_replace/output.tf b/examples/modules/fetch_replace/output.tf deleted file mode 100644 index 9ad29b1..0000000 --- a/examples/modules/fetch_replace/output.tf +++ /dev/null @@ -1,15 +0,0 @@ -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 -} \ No newline at end of file diff --git a/examples/modules/fetch_replace/variables.tf b/examples/modules/fetch_replace/variables.tf deleted file mode 100644 index de3e5bb..0000000 --- a/examples/modules/fetch_replace/variables.tf +++ /dev/null @@ -1,9 +0,0 @@ -variable "rsubfolder" { - type = string - default = "config/profile-2.0" -} - -variable "rprefix" { - type = string - default = "infra-" -} \ No newline at end of file diff --git a/examples/modules/fetcher/main.tf b/examples/modules/fetcher/main.tf deleted file mode 100644 index 9a4c124..0000000 --- a/examples/modules/fetcher/main.tf +++ /dev/null @@ -1,28 +0,0 @@ -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"])) -} \ No newline at end of file diff --git a/examples/modules/fetcher/output.tf b/examples/modules/fetcher/output.tf deleted file mode 100644 index 66a00c3..0000000 --- a/examples/modules/fetcher/output.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "object_files" { - value = local.object_files -} \ No newline at end of file diff --git a/examples/modules/fetcher/variables.tf b/examples/modules/fetcher/variables.tf deleted file mode 100644 index de3e5bb..0000000 --- a/examples/modules/fetcher/variables.tf +++ /dev/null @@ -1,9 +0,0 @@ -variable "rsubfolder" { - type = string - default = "config/profile-2.0" -} - -variable "rprefix" { - type = string - default = "infra-" -} \ No newline at end of file diff --git a/examples/modules/replacer/main.tf b/examples/modules/replacer/main.tf deleted file mode 100644 index 29b53f7..0000000 --- a/examples/modules/replacer/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -locals { - all_objects_params_replaced = tomap({ - for k, v in var.objects : k => yamldecode(templatefile(v, var.params)) - }) -} \ No newline at end of file diff --git a/examples/modules/replacer/output.tf b/examples/modules/replacer/output.tf deleted file mode 100644 index e2bf05d..0000000 --- a/examples/modules/replacer/output.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "all_objects_params_replaced" { - value = local.all_objects_params_replaced -} \ No newline at end of file diff --git a/examples/modules/replacer/variables.tf b/examples/modules/replacer/variables.tf deleted file mode 100644 index 148abb5..0000000 --- a/examples/modules/replacer/variables.tf +++ /dev/null @@ -1,9 +0,0 @@ -variable "objects" { - type = list(any) - default = [] -} - -variable "params" { - type = map - default = {} -} \ No newline at end of file diff --git a/examples/providers.tf b/examples/providers.tf index 665b887..20f842a 100644 --- a/examples/providers.tf +++ b/examples/providers.tf @@ -18,7 +18,7 @@ variable "sc_username" { variable "sc_password" { description = "Spectro Cloud Password" - sensitive = true + //sensitive = true } variable "sc_project_name" { diff --git a/main.tf b/main.tf index 665b887..20f842a 100644 --- a/main.tf +++ b/main.tf @@ -18,7 +18,7 @@ variable "sc_username" { variable "sc_password" { description = "Spectro Cloud Password" - sensitive = true + //sensitive = true } variable "sc_project_name" { diff --git a/spectro-aws-account.tf b/spectro-aws-account.tf index 10e1631..a56aaeb 100644 --- a/spectro-aws-account.tf +++ b/spectro-aws-account.tf @@ -12,6 +12,10 @@ data "spectrocloud_cloudaccount_aws" "this" { for_each = local.cloud_account_names name = each.value + + depends_on = [ + resource.spectrocloud_cloudaccount_aws.account + ] } resource "spectrocloud_cloudaccount_aws" "account" { diff --git a/spectro-profile.tf b/spectro-profile.tf index 307e957..d14758c 100644 --- a/spectro-profile.tf +++ b/spectro-profile.tf @@ -53,9 +53,13 @@ data "spectrocloud_cluster_profile" "this" { for_each = local.profile_names name = each.value + + depends_on = [ + resource.spectrocloud_cluster_profile.profile_resource + ] } -resource "spectrocloud_cluster_profile" "infra" { +resource "spectrocloud_cluster_profile" "profile_resource" { for_each = var.profiles name = each.value.name description = each.value.description diff --git a/spectro-s3-sts-backup.tf b/spectro-s3-sts-backup.tf index 1479d84..3c6b298 100644 --- a/spectro-s3-sts-backup.tf +++ b/spectro-s3-sts-backup.tf @@ -11,6 +11,10 @@ data "spectrocloud_backup_storage_location" "this" { for_each = local.bsl_names name = each.value + + depends_on = [ + resource.spectrocloud_backup_storage_location.bsl + ] } resource "spectrocloud_backup_storage_location" "bsl" { diff --git a/variables.tf b/variables.tf index e856966..b8b666f 100644 --- a/variables.tf +++ b/variables.tf @@ -23,7 +23,6 @@ variable "teams" { } variable "clusters" { - type = map(any) default = {} }