From 946d173e7b85437867edf36ec4bd1c4a4c8c94dd Mon Sep 17 00:00:00 2001 From: Jay Chung Date: Fri, 14 Jul 2023 09:52:16 +0800 Subject: [PATCH] fix terrafrom config bug (#14362) (cherry picked from commit b5d88f2a6fbcb333c533bb0e53b6cb8671e7cec0) --- deploy/terraform/aws/.terraform.lock.hcl | 73 ++++++++----------- deploy/terraform/aws/README.md | 5 +- .../terraform/aws/dolphinscheduler-worker.tf | 1 + deploy/terraform/aws/s3-main.tf | 12 +-- deploy/terraform/aws/zookeeper-main.tf | 3 +- 5 files changed, 45 insertions(+), 49 deletions(-) diff --git a/deploy/terraform/aws/.terraform.lock.hcl b/deploy/terraform/aws/.terraform.lock.hcl index b80b60b054c0..269f8091c319 100644 --- a/deploy/terraform/aws/.terraform.lock.hcl +++ b/deploy/terraform/aws/.terraform.lock.hcl @@ -2,67 +2,58 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.42.0" + version = "5.1.0" + constraints = ">= 4.9.0" hashes = [ - "h1:cS7q80JomJrUZpm+bnK5H/iRjF5+7HAA3qgw+JznPiM=", - "zh:091b64bccee701462b19ca99fe3bff0716e9445a88d0e4d0d0f322062b02bb60", - "zh:1fd9b0bf3421ad65284d693e60de068fc9b247d4fa7df6c1d62ad4796088f795", - "zh:3e34e4fcfaa30b04811aaa92c4d6115ddaa820ac11fa82ad217f42ae17a068ea", - "zh:47b412ab9cc3730797659ffb775a429b5398a5f403c9cca2ec5f663e21a69077", - "zh:8e29e90fdf29d76bb8fab62c184c4ec78e37030277dbe2c0dd97557fdfcbcb50", - "zh:8ef4e94b5672234a68649bdbb93416c1829c5cd6f37be584f8e8610f14ca95b0", - "zh:92a3eb5ae0c2c83717973c56b0427bf1fe8fba3ba72ced01e5eefc5c0cff8bf3", - "zh:96b9f714aed24206f8f47af39426aa8c02f172ac6d5516bcc375583d120bf4f8", - "zh:996ec2065cf0c52b125e3ac8bbd059e5733d8393143cebbb427a236d08c742b4", + "h1:iDyYmwv8q94Dvr4DRG1KBxTWPZRFkRmKGa3cjCEsPZU=", + "zh:0c48f157b804c1f392adb5c14b81e756c652755e358096300ea8dd1283021129", + "zh:1a50495a6c0e5665e51df57dac6e781ec71439b11ebf05f971b6f3a3eb4eb7b2", + "zh:2959ff472c05e56d59e012118dd8d55022f005534c0ae961ce81136de9f66a4d", + "zh:2dfda9133581b99ed6e709e89a453fd2974ce88c703d3e073ec31bf99d7508ce", + "zh:2f3d92cc7a6624da42cee2202f8fb23e6d38f156ab7851884d637282cb0dc709", + "zh:3bc2a34d09cbaf439a1815846904f070c782cd8dfd60b5e0116827cda25f7549", + "zh:4ef43f1a247aa8de8690ac3bbc2b00ebaf6b2872fc8d0f5130e4a8130c874b87", + "zh:5477cb272dcaeb0030091bcf23a9f0f33b5410e44e317e9d3d49446f545dbaa4", + "zh:734c8fb4c0b79c82dd757566761dda5b91ee1ef9a2b848a748ade11e0e1cc69f", + "zh:80346c051b677f4f018da7fe06318b87c5bd0f1ec67ce78ab33baed3bb8b031a", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:b3abba32ccbea87b6a46e846c878ca0b2e9736dbaedd512a712398ece91de431", - "zh:b77292051d499f66ed80434ac435930204b92ca906c0d38fdb8a0ac37efa25ae", - "zh:f4ed19b15bd7cd99ee248023a94a10d586e69f81d0d8326d87a79cc37b579a4f", - "zh:f906a8003e6ad0dd561d8c62e02a65835d8c5009dd7cbfe03e28becced82e5db", - "zh:faff211d1559cbae669b63cdd6436a2ef0fb24108d8fa73b625dc5334b50aada", + "zh:a865b2f88dfee13df14116c5cf53d033d2c15855f4b59b9c65337309a928df2c", + "zh:c0345f266eedaece5612c1000722b302f895d1bc5af1d5a4265f0e7000ca48bb", + "zh:d59703c8e6a9d8b4fbd3b4583b945dfff9cb2844c762c0b3990e1cef18282279", + "zh:d8d04a6a6cd2dfcb23b57e551db7b15e647f6166310fb7d883d8ec67bdc9bdc8", ] } provider "registry.terraform.io/hashicorp/local" { - version = "2.2.3" + version = "2.4.0" hashes = [ - "h1:KmHz81iYgw9Xn2L3Carc2uAzvFZ1XsE7Js3qlVeC77k=", - "zh:04f0978bb3e052707b8e82e46780c371ac1c66b689b4a23bbc2f58865ab7d5c0", - "zh:6484f1b3e9e3771eb7cc8e8bab8b35f939a55d550b3f4fb2ab141a24269ee6aa", - "zh:78a56d59a013cb0f7eb1c92815d6eb5cf07f8b5f0ae20b96d049e73db915b238", + "h1:ZUEYUmm2t4vxwzxy1BvN1wL6SDWrDxfH7pxtzX8c6d0=", + "zh:53604cd29cb92538668fe09565c739358dc53ca56f9f11312b9d7de81e48fab9", + "zh:66a46e9c508716a1c98efbf793092f03d50049fa4a83cd6b2251e9a06aca2acf", + "zh:70a6f6a852dd83768d0778ce9817d81d4b3f073fab8fa570bff92dcb0824f732", "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:8aa9950f4c4db37239bcb62e19910c49e47043f6c8587e5b0396619923657797", - "zh:996beea85f9084a725ff0e6473a4594deb5266727c5f56e9c1c7c62ded6addbb", - "zh:9a7ef7a21f48fabfd145b2e2a4240ca57517ad155017e86a30860d7c0c109de3", - "zh:a63e70ac052aa25120113bcddd50c1f3cfe61f681a93a50cea5595a4b2cc3e1c", - "zh:a6e8d46f94108e049ad85dbed60354236dc0b9b5ec8eabe01c4580280a43d3b8", - "zh:bb112ce7efbfcfa0e65ed97fa245ef348e0fd5bfa5a7e4ab2091a9bd469f0a9e", - "zh:d7bec0da5c094c6955efed100f3fe22fca8866859f87c025be1760feb174d6d9", - "zh:fb9f271b72094d07cef8154cd3d50e9aa818a0ea39130bc193132ad7b23076fd", + "zh:82a803f2f484c8b766e2e9c32343e9c89b91997b9f8d2697f9f3837f62926b35", + "zh:9708a4e40d6cc4b8afd1352e5186e6e1502f6ae599867c120967aebe9d90ed04", + "zh:973f65ce0d67c585f4ec250c1e634c9b22d9c4288b484ee2a871d7fa1e317406", + "zh:c8fa0f98f9316e4cfef082aa9b785ba16e36ff754d6aba8b456dab9500e671c6", + "zh:cfa5342a5f5188b20db246c73ac823918c189468e1382cb3c48a9c0c08fc5bf7", + "zh:e0e2b477c7e899c63b06b38cd8684a893d834d6d0b5e9b033cedc06dd7ffe9e2", + "zh:f62d7d05ea1ee566f732505200ab38d94315a4add27947a60afa29860822d3fc", + "zh:fa7ce69dde358e172bd719014ad637634bbdabc49363104f4fca759b4b73f2ce", ] } provider "registry.terraform.io/hashicorp/template" { version = "2.2.0" hashes = [ - "h1:0wlehNaxBX7GJQnPfQwTNvvAf38Jm0Nv7ssKGMaG6Og=", - "zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386", - "zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53", - "zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603", - "zh:0e3a6c8e16f17f19010accd0844187d524580d9fdb0731f675ffcf4afba03d16", - "zh:45f2c594b6f2f34ea663704cc72048b212fe7d16fb4cfd959365fa997228a776", - "zh:77ea3e5a0446784d77114b5e851c970a3dde1e08fa6de38210b8385d7605d451", - "zh:8a154388f3708e3df5a69122a23bdfaf760a523788a5081976b3d5616f7d30ae", - "zh:992843002f2db5a11e626b3fc23dc0c87ad3729b3b3cff08e32ffb3df97edbde", - "zh:ad906f4cebd3ec5e43d5cd6dc8f4c5c9cc3b33d2243c89c5fc18f97f7277b51d", - "zh:c979425ddb256511137ecd093e23283234da0154b7fa8b21c2687182d9aea8b2", + "h1:C0epDvyWsN2Roo+yua2ltW61FVHEOsXHaM43Fj9bMA8=", ] } provider "registry.terraform.io/hashicorp/tls" { version = "4.0.4" hashes = [ - "h1:Wd3RqmQW60k2QWPN4sK5CtjGuO1d+CRNXgC+D4rKtXc=", + "h1:GZcFizg5ZT2VrpwvxGBHQ/hO9r6g0vYdQqx3bFD3anY=", "zh:23671ed83e1fcf79745534841e10291bbf34046b27d6e68a5d0aab77206f4a55", "zh:45292421211ffd9e8e3eb3655677700e3c5047f71d8f7650d2ce30242335f848", "zh:59fedb519f4433c0fdb1d58b27c210b27415fddd0cd73c5312530b4309c088be", diff --git a/deploy/terraform/aws/README.md b/deploy/terraform/aws/README.md index c822a2322d59..922901afe61f 100644 --- a/deploy/terraform/aws/README.md +++ b/deploy/terraform/aws/README.md @@ -7,7 +7,7 @@ Set necessary variables by creating a file `ds-ami.pkrvars.hcl` and adding the following variables according to your own usage. -```hcl +```shel cat < ds-ami.pkrvars.hcl aws_access_key = "" aws_secret_key = "" @@ -17,7 +17,7 @@ aws_region = "cn-north-1" ds_ami_name = "my-test-ds-2" # If you want to use the official distribution tar, just set the `ds_version` to the one you want. -ds_version = 3.1.1 +ds_version = "3.1.1" # If you want to use a locally built distribution tar, set the `ds_tar` to the tar file location. ds_tar = "~/workspace/dolphinscheduler/dolphinscheduler-dist/target/apache-dolphinscheduler-3.1.3-SNAPSHOT-bin.tar.gz" @@ -50,6 +50,7 @@ Make sure `ds_ami_name` is the same as the one in `ds-ami.pkrvars.hcl` above. cat < terraform.tfvars aws_access_key = "" aws_secret_key = "" +aws_region = "" name_prefix = "test-ds-terraform" ds_ami_name = "my-test-ds" diff --git a/deploy/terraform/aws/dolphinscheduler-worker.tf b/deploy/terraform/aws/dolphinscheduler-worker.tf index 97f402b5fb89..a3404cf96a62 100644 --- a/deploy/terraform/aws/dolphinscheduler-worker.tf +++ b/deploy/terraform/aws/dolphinscheduler-worker.tf @@ -57,6 +57,7 @@ data "template_file" "worker_user_data" { "database_username" = aws_db_instance.database.username "database_password" = aws_db_instance.database.password "zookeeper_connect_string" = var.zookeeper_connect_string != "" ? var.zookeeper_connect_string : aws_instance.zookeeper[0].private_ip + "alert_server_host" = "" "s3_access_key_id" = aws_iam_access_key.s3.id "s3_secret_access_key" = aws_iam_access_key.s3.secret "s3_region" = var.aws_region diff --git a/deploy/terraform/aws/s3-main.tf b/deploy/terraform/aws/s3-main.tf index 32428b4b0c2d..018865049564 100644 --- a/deploy/terraform/aws/s3-main.tf +++ b/deploy/terraform/aws/s3-main.tf @@ -19,11 +19,13 @@ module "s3_bucket" { source = "terraform-aws-modules/s3-bucket/aws" version = "~> 3.6" - bucket_prefix = var.s3_bucket_prefix - acl = "private" - force_destroy = true - attach_policy = true - policy = data.aws_iam_policy_document.s3.json + bucket_prefix = var.s3_bucket_prefix + acl = "private" + control_object_ownership = true + object_ownership = "ObjectWriter" + force_destroy = true + attach_policy = true + policy = data.aws_iam_policy_document.s3.json } resource "aws_iam_user" "s3" { diff --git a/deploy/terraform/aws/zookeeper-main.tf b/deploy/terraform/aws/zookeeper-main.tf index d39ebf812858..9c03d68266aa 100644 --- a/deploy/terraform/aws/zookeeper-main.tf +++ b/deploy/terraform/aws/zookeeper-main.tf @@ -68,6 +68,7 @@ resource "aws_instance" "zookeeper" { vpc_security_group_ids = [aws_security_group.zookeeper_sg[count.index].id] source_dest_check = false associate_public_ip_address = var.vm_associate_public_ip_address.standalone_server + key_name = aws_key_pair.key_pair.key_name user_data = data.template_file.zookeeper_user_data.rendered @@ -94,7 +95,7 @@ resource "aws_instance" "zookeeper" { connection { type = "ssh" - user = "root" + user = "ec2-user" private_key = tls_private_key.key_pair.private_key_pem host = self.public_ip timeout = "30s"