diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index ab0d903..476c6c6 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -6,7 +6,7 @@ name: 'terraform' on: push: branches: - - master + - main pull_request: jobs: @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - tf: [0.13.2] + tf: [1] steps: - name: Checkout from Github uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index a7ac1de..e395803 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ override.tf.json # Include override files you do wish to add to version control using negated pattern # # !example_override.tf -!.terraform.lock.hcl +.terraform.lock.hcl # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl deleted file mode 100644 index e97de05..0000000 --- a/.terraform.lock.hcl +++ /dev/null @@ -1,153 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/equinix/metal" { - version = "3.2.1" - hashes = [ - "h1:ZlFTM53deZU/b5I1CopmZEgmuhY7C8Z16Ko8/wF7E7g=", - "zh:001983330b8845ad07f1e7d8462cd2ba2f372d54523d64e382ae5bdd4fe690a5", - "zh:1ec8c9052c01acd43f10ac92998b715b693640bb1f53e4dad7b4f5b2a2b84574", - "zh:27785aec3fa7d4b1d4638a7eb36ae70d15fe457e3371365bc16a8fb1349d9649", - "zh:2a6b6cfb08a52f32e66142b21c3df72da3e66d5158a61e4fd1d56f29772b5460", - "zh:57309a5d762744588c4a9ff3592fa446e123e62bd1ec6e502671375075d35647", - "zh:636c16ef8acc57605a0dc011dc05ef00276980553b70a2b35ab09185434902f7", - "zh:6b31691a28f1e6877e5c48894acdcc463f0baa74ae254a2acf6e148971f87810", - "zh:84c82012f51f82977b27084e1d7410c020a5772645f3037c25f7e3df1a637611", - "zh:9ea35a527e95280f3440abf2670c449951c239f1ce5e8fd685e04af60b2d28ff", - "zh:a81ef5a2f29b928c23a83c86e157daa604e70c3ef9e2d49b494556103b58e9ad", - "zh:d2bc396da3a1b0110b64a305f09092136e3b10e4cdf99a4f1e013e01ffa6812d", - "zh:ed783f06adc8702ce6c171a23f918c998c89836a6fe8f4e4c7cd15b84b8708a5", - "zh:fde39924aa0de90b7d19da2dd4f561a7a8c92efb9e19ea1c319957ccd6019fdd", - ] -} - -provider "registry.terraform.io/hashicorp/cloudinit" { - version = "2.2.0" - hashes = [ - "h1:siiI0wK6/jUDdA5P8ifTO0yc9YmXHml4hz5K9I9N+MA=", - "zh:76825122171f9ea2287fd27e23e80a7eb482f6491a4f41a096d77b666896ee96", - "zh:795a36dee548e30ca9c9d474af9ad6d29290e0a9816154ad38d55381cd0ab12d", - "zh:9200f02cb917fb99e44b40a68936fd60d338e4d30a718b7e2e48024a795a61b9", - "zh:a33cf255dc670c20678063aa84218e2c1b7a67d557f480d8ec0f68bc428ed472", - "zh:ba3c1b2cd0879286c1f531862c027ec04783ece81de67c9a3b97076f1ce7f58f", - "zh:bd575456394428a1a02191d2e46af0c00e41fd4f28cfe117d57b6aeb5154a0fb", - "zh:c68dd1db83d8437c36c92dc3fc11d71ced9def3483dd28c45f8640cfcd59de9a", - "zh:cbfe34a90852ed03cc074601527bb580a648127255c08589bc3ef4bf4f2e7e0c", - "zh:d6ffd7398c6d1f359b96f5b757e77b99b339fbb91df1b96ac974fe71bc87695c", - "zh:d9c15285f847d7a52df59e044184fb3ba1b7679fd0386291ed183782683d9517", - "zh:f7dd02f6d36844da23c9a27bb084503812c29c1aec4aba97237fec16860fdc8c", - ] -} - -provider "registry.terraform.io/hashicorp/google" { - version = "3.53.0" - constraints = "~> 3.53.0" - hashes = [ - "h1:0MYwK1KRNCc9lfF8vV9gDEuaylwEfSPws7ZJbLwY2FE=", - "h1:AzrT8ueZHo7GrEWFiXi3eB/NOQoXcVE/w6fLcRJyc34=", - "zh:1408365b5f2ae508fce9b446bb9dbaf044aec81fa4c36fff39c2511b179bcc56", - "zh:1d53e978065feb6278bc8c88a70c3df7599c3b8bbcd77765bcd842a83bce6686", - "zh:5173a92249c8d06d0d2beca0e328df6e956becd789ebae9a064f022151415b8f", - "zh:5bd2ee6cd6baf2cb429f82140cbb5e6c90362b0ef4edaf63df30520e01507374", - "zh:65670355fddde75bfadc088627e2700dc14054a63aa5434d2759e7fe43b989c6", - "zh:97d4382855c50a2077d3ecd241a02324b8ba2cb8b8c76f8f896c40189260f6c1", - "zh:9a18ad92e062dcd2ef72ed9021d5827326a2fc13c2c442c54baf6a9298035873", - "zh:b4941a0f47f05c965af42821d51748ac326aea2843b123663dd50f7075fa1956", - "zh:f40bbb7046dfcd12ddef175acb1cfc4a8ae082f56a24ba413f0719747789915b", - "zh:f60769112a2e36beb762dc7f31916f818b5cacfb35d7d8ddeb40ea6bf8690e9e", - ] -} - -provider "registry.terraform.io/hashicorp/local" { - version = "2.1.0" - hashes = [ - "h1:EYZdckuGU3n6APs97nS2LxZm3dDtGqyM4qaIvsmac8o=", - "h1:KfieWtVyGWwplSoLIB5usKAUnrIkDQBkWaR5TI+4WYg=", - "zh:0f1ec65101fa35050978d483d6e8916664b7556800348456ff3d09454ac1eae2", - "zh:36e42ac19f5d68467aacf07e6adcf83c7486f2e5b5f4339e9671f68525fc87ab", - "zh:6db9db2a1819e77b1642ec3b5e95042b202aee8151a0256d289f2e141bf3ceb3", - "zh:719dfd97bb9ddce99f7d741260b8ece2682b363735c764cac83303f02386075a", - "zh:7598bb86e0378fd97eaa04638c1a4c75f960f62f69d3662e6d80ffa5a89847fe", - "zh:ad0a188b52517fec9eca393f1e2c9daea362b33ae2eb38a857b6b09949a727c1", - "zh:c46846c8df66a13fee6eff7dc5d528a7f868ae0dcf92d79deaac73cc297ed20c", - "zh:dc1a20a2eec12095d04bf6da5321f535351a594a636912361db20eb2a707ccc4", - "zh:e57ab4771a9d999401f6badd8b018558357d3cbdf3d33cc0c4f83e818ca8e94b", - "zh:ebdcde208072b4b0f8d305ebf2bfdc62c926e0717599dcf8ec2fd8c5845031c3", - "zh:ef34c52b68933bedd0868a13ccfd59ff1c820f299760b3c02e008dc95e2ece91", - ] -} - -provider "registry.terraform.io/hashicorp/null" { - version = "3.1.0" - hashes = [ - "h1:vpC6bgUQoJ0znqIKVFevOdq+YQw42bRq0u+H3nto8nA=", - "h1:xhbHC6in3nQryvTQBWKxebi3inG5OCgHgc4fRxL0ymc=", - "zh:02a1675fd8de126a00460942aaae242e65ca3380b5bb192e8773ef3da9073fd2", - "zh:53e30545ff8926a8e30ad30648991ca8b93b6fa496272cd23b26763c8ee84515", - "zh:5f9200bf708913621d0f6514179d89700e9aa3097c77dac730e8ba6e5901d521", - "zh:9ebf4d9704faba06b3ec7242c773c0fbfe12d62db7d00356d4f55385fc69bfb2", - "zh:a6576c81adc70326e4e1c999c04ad9ca37113a6e925aefab4765e5a5198efa7e", - "zh:a8a42d13346347aff6c63a37cda9b2c6aa5cc384a55b2fe6d6adfa390e609c53", - "zh:c797744d08a5307d50210e0454f91ca4d1c7621c68740441cf4579390452321d", - "zh:cecb6a304046df34c11229f20a80b24b1603960b794d68361a67c5efe58e62b8", - "zh:e1371aa1e502000d9974cfaff5be4cfa02f47b17400005a16f14d2ef30dc2a70", - "zh:fc39cc1fe71234a0b0369d5c5c7f876c71b956d23d7d6f518289737a001ba69b", - "zh:fea4227271ebf7d9e2b61b89ce2328c7262acd9fd190e1fd6d15a591abfa848e", - ] -} - -provider "registry.terraform.io/hashicorp/random" { - version = "3.1.0" - hashes = [ - "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", - "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", - "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", - "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", - "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", - "zh:7011332745ea061e517fe1319bd6c75054a314155cb2c1199a5b01fe1889a7e2", - "zh:738ed82858317ccc246691c8b85995bc125ac3b4143043219bd0437adc56c992", - "zh:7dbe52fac7bb21227acd7529b487511c91f4107db9cc4414f50d04ffc3cab427", - "zh:a3a9251fb15f93e4cfc1789800fc2d7414bbc18944ad4c5c98f466e6477c42bc", - "zh:a543ec1a3a8c20635cf374110bd2f87c07374cf2c50617eee2c669b3ceeeaa9f", - "zh:d9ab41d556a48bd7059f0810cf020500635bfc696c9fc3adab5ea8915c1d886b", - "zh:d9e13427a7d011dbd654e591b0337e6074eef8c3b9bb11b2e39eaaf257044fd7", - "zh:f7605bd1437752114baf601bdf6931debe6dc6bfe3006eb7e9bb9080931dca8a", - ] -} - -provider "registry.terraform.io/hashicorp/template" { - version = "2.2.0" - hashes = [ - "h1:0wlehNaxBX7GJQnPfQwTNvvAf38Jm0Nv7ssKGMaG6Og=", - "h1:94qn780bi1qjrbC3uQtjJh3Wkfwd5+tTtJHOb7KTg9w=", - "zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386", - "zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53", - "zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603", - "zh:0e3a6c8e16f17f19010accd0844187d524580d9fdb0731f675ffcf4afba03d16", - "zh:45f2c594b6f2f34ea663704cc72048b212fe7d16fb4cfd959365fa997228a776", - "zh:77ea3e5a0446784d77114b5e851c970a3dde1e08fa6de38210b8385d7605d451", - "zh:8a154388f3708e3df5a69122a23bdfaf760a523788a5081976b3d5616f7d30ae", - "zh:992843002f2db5a11e626b3fc23dc0c87ad3729b3b3cff08e32ffb3df97edbde", - "zh:ad906f4cebd3ec5e43d5cd6dc8f4c5c9cc3b33d2243c89c5fc18f97f7277b51d", - "zh:c979425ddb256511137ecd093e23283234da0154b7fa8b21c2687182d9aea8b2", - ] -} - -provider "registry.terraform.io/hashicorp/tls" { - version = "3.1.0" - hashes = [ - "h1:XTU9f6sGMZHOT8r/+LWCz2BZOPH127FBTPjMMEAAu1U=", - "h1:fUJX8Zxx38e2kBln+zWr1Tl41X+OuiE++REjrEyiOM4=", - "zh:3d46616b41fea215566f4a957b6d3a1aa43f1f75c26776d72a98bdba79439db6", - "zh:623a203817a6dafa86f1b4141b645159e07ec418c82fe40acd4d2a27543cbaa2", - "zh:668217e78b210a6572e7b0ecb4134a6781cc4d738f4f5d09eb756085b082592e", - "zh:95354df03710691773c8f50a32e31fca25f124b7f3d6078265fdf3c4e1384dca", - "zh:9f97ab190380430d57392303e3f36f4f7835c74ea83276baa98d6b9a997c3698", - "zh:a16f0bab665f8d933e95ca055b9c8d5707f1a0dd8c8ecca6c13091f40dc1e99d", - "zh:be274d5008c24dc0d6540c19e22dbb31ee6bfdd0b2cddd4d97f3cd8a8d657841", - "zh:d5faa9dce0a5fc9d26b2463cea5be35f8586ab75030e7fa4d4920cd73ee26989", - "zh:e9b672210b7fb410780e7b429975adcc76dd557738ecc7c890ea18942eb321a5", - "zh:eb1f8368573d2370605d6dbf60f9aaa5b64e55741d96b5fb026dbfe91de67c0d", - "zh:fc1e12b713837b85daf6c3bb703d7795eaf1c5177aebae1afcf811dd7009f4b0", - ] -} diff --git a/main.tf b/main.tf index f6980e5..969bc74 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,5 @@ provider "equinix" { - auth_token = var.equinix_metal_auth_token + auth_token = var.metal_auth_token } provider "google" { @@ -13,9 +13,9 @@ resource "random_string" "cluster_suffix" { } resource "equinix_metal_project" "new_project" { - count = var.equinix_metal_create_project ? 1 : 0 - name = var.equinix_metal_project_name - organization_id = var.equinix_metal_organization_id + count = var.metal_create_project ? 1 : 0 + name = var.metal_project_name + organization_id = var.metal_organization_id bgp_config { deployment_type = "local" asn = var.bgp_asn @@ -28,7 +28,7 @@ locals { timestamp = timestamp() timestamp_sanitized = replace(local.timestamp, "/[- TZ:]/", "") ssh_key_name = format("anthos-%s-%s", var.cluster_name, random_string.cluster_suffix.result) - metal_project_id = var.equinix_metal_create_project ? equinix_metal_project.new_project[0].id : var.equinix_metal_project_id + metal_project_id = var.metal_create_project ? equinix_metal_project.new_project[0].id : var.metal_project_id gcr_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.gcr_sa_key[0].private_key) : file("${var.gcp_keys_path}/gcr.json") connect_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.connect_sa_key[0].private_key) : file("${var.gcp_keys_path}/connect.json") register_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.register_sa_key[0].private_key) : file("${var.gcp_keys_path}/register.json") @@ -97,12 +97,12 @@ data "cloudinit_config" "cp_user_data" { eip = cidrhost(equinix_metal_reserved_ip_block.cp_vip.cidr_notation, 0) count = 0 kube_vip_ver = var.kube_vip_version - auth_token = var.equinix_metal_auth_token + auth_token = var.metal_auth_token project_id = local.metal_project_id }) ccm_secret = templatefile("${path.module}/templates/ccm_secret.yaml", { - auth_token = var.equinix_metal_auth_token + auth_token = var.metal_auth_token project_id = local.metal_project_id }) }) @@ -298,7 +298,7 @@ resource "null_resource" "kube_vip_install_remaining_cp" { eip = cidrhost(equinix_metal_reserved_ip_block.cp_vip.cidr_notation, 0) count = 1 kube_vip_ver = var.kube_vip_version - auth_token = var.equinix_metal_auth_token + auth_token = var.metal_auth_token project_id = local.metal_project_id }) diff --git a/variables.tf b/variables.tf index 22eef26..4570c50 100644 --- a/variables.tf +++ b/variables.tf @@ -1,15 +1,15 @@ -variable "equinix_metal_auth_token" { +variable "metal_auth_token" { type = string description = "Equinix Metal API Key" } -variable "equinix_metal_project_id" { +variable "metal_project_id" { type = string default = "null" description = "Equinix Metal Project ID" } -variable "equinix_metal_organization_id" { +variable "metal_organization_id" { type = string default = "null" description = "Equinix Metal Organization ID" @@ -73,13 +73,13 @@ variable "cluster_name" { } } -variable "equinix_metal_create_project" { +variable "metal_create_project" { type = bool default = true - description = "Create a Metal Project if this is 'true'. Else use provided 'equinix_metal_project_id'" + description = "Create a Metal Project if this is 'true'. Else use provided 'metal_project_id'" } -variable "equinix_metal_project_name" { +variable "metal_project_name" { type = string default = "baremetal-anthos" description = "The name of the Metal project if 'create_project' is 'true'."