ds-ami-official.pkr.hcl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. variable "aws_access_key" {
  18. type = string
  19. description = "AWS access key"
  20. }
  21. variable "aws_secret_key" {
  22. type = string
  23. description = "AWS secret key"
  24. }
  25. variable "aws_region" {
  26. type = string
  27. description = "AWS region"
  28. default = "cn-north-1"
  29. }
  30. variable "ds_version" {
  31. type = string
  32. description = "DolphinScheduler Version"
  33. default = "3.1.1"
  34. }
  35. variable "ds_ami_name" {
  36. type = string
  37. description = "Name of DolphinScheduler AMI"
  38. default = "dolphinscheduler-ami"
  39. }
  40. packer {
  41. required_plugins {
  42. amazon = {
  43. version = ">= 0.0.1"
  44. source = "github.com/hashicorp/amazon"
  45. }
  46. }
  47. }
  48. source "amazon-ebs" "linux" {
  49. access_key = var.aws_access_key
  50. secret_key = var.aws_secret_key
  51. region = var.aws_region
  52. ami_name = var.ds_ami_name
  53. instance_type = "t2.micro"
  54. source_ami_filter {
  55. filters = {
  56. name = "al2022-ami-*"
  57. root-device-type = "ebs"
  58. virtualization-type = "hvm"
  59. architecture = "x86_64"
  60. }
  61. most_recent = true
  62. owners = ["amazon"]
  63. }
  64. ssh_username = "ec2-user"
  65. }
  66. build {
  67. name = "dolphinscheduler-ami"
  68. sources = [
  69. "source.amazon-ebs.linux"
  70. ]
  71. provisioner "shell" {
  72. inline = [
  73. "sudo yum remove -y java",
  74. "sudo yum install -y java-1.8.0-amazon-corretto.x86_64",
  75. "echo 'export JAVA_HOME=/etc/alternatives/jre' | sudo tee /etc/profile.d/java_home.sh",
  76. "sudo mkdir -p /opt/dolphinscheduler",
  77. "curl -Ls http://archive.apache.org/dist/dolphinscheduler/${var.ds_version}/apache-dolphinscheduler-${var.ds_version}-bin.tar.gz | sudo tar zxvf - --strip-components 1 -C /opt/dolphinscheduler",
  78. "sudo find /opt/dolphinscheduler/ -name start.sh | xargs -I{} sudo chmod +x {}",
  79. ]
  80. }
  81. }