# Prerequisites - [Packer](https://developer.hashicorp.com/packer/downloads) - [Terraform](https://developer.hashicorp.com/terraform/downloads?ajs_aid=e8824c6e-5f6f-480c-bb7d-27f8c97f8d8d&product_intent=terraform) # Build AMI Set necessary variables by creating a file `ds-ami.pkrvars.hcl` and adding the following variables according to your own usage. ```shel cat < ds-ami.pkrvars.hcl aws_access_key = "" aws_secret_key = "" 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" # 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" EOF ``` Then run the following command to initialize and build a custom AMI. - If you want to use the official distribution tar. ```shell packer init --var-file=ds-ami.pkrvars.hcl packer/ds-ami-official.pkr.hcl packer build --var-file=ds-ami.pkrvars.hcl packer/ds-ami-official.pkr.hcl ``` - If you want to use the locally built distribution tar. ```shell packer init --var-file=ds-ami.pkrvars.hcl packer/ds-ami-local.pkr.hcl packer build --var-file=ds-ami.pkrvars.hcl packer/ds-ami-local.pkr.hcl ``` # Create resources Set necessary variables by creating a file `terraform.tfvars` and adding the following variables according to your own usage. Make sure `ds_ami_name` is the same as the one in `ds-ami.pkrvars.hcl` above. ```tfvars cat < terraform.tfvars aws_access_key = "" aws_secret_key = "" aws_region = "" name_prefix = "test-ds-terraform" ds_ami_name = "my-test-ds" ds_component_replicas = { master = 1 worker = 1 alert = 1 api = 1 standalone_server = 0 } EOF ``` Then run the following commands to apply necessary resources. ```shell terraform init -var-file=terraform.tfvars terraform apply -var-file=terraform.tfvars -auto-approve ``` # Open DolphinScheduler UI ```shell open http://$(terraform output -json api_server_instance_public_dns | jq -r '.[0]'):12345/dolphinscheduler/ui ``` # Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [aws\_access\_key](#input\_aws\_access\_key) | AWS access key | `string` | n/a | yes | | [aws\_region](#input\_aws\_region) | AWS region | `string` | `"cn-north-1"` | no | | [aws\_secret\_key](#input\_aws\_secret\_key) | AWS secret key | `string` | n/a | yes | | [db\_instance\_class](#input\_db\_instance\_class) | Database instance class | `string` | `"db.t3.micro"` | no | | [db\_password](#input\_db\_password) | Database password | `string` | n/a | yes | | [db\_username](#input\_db\_username) | Database username | `string` | `"dolphinscheduler"` | no | | [ds\_ami\_name](#input\_ds\_ami\_name) | Name of DolphinScheduler AMI | `string` | `"dolphinscheduler-ami"` | no | | [ds\_component\_replicas](#input\_ds\_component\_replicas) | Replicas of the DolphinScheduler Components | `map(number)` |
{
"alert": 1,
"api": 1,
"master": 1,
"standalone_server": 0,
"worker": 1
}
| no | | [ds\_version](#input\_ds\_version) | DolphinScheduler Version | `string` | `"3.1.1"` | no | | [name\_prefix](#input\_name\_prefix) | Name prefix for all resources | `string` | `"dolphinscheduler"` | no | | [private\_subnet\_cidr\_blocks](#input\_private\_subnet\_cidr\_blocks) | Available CIDR blocks for private subnets | `list(string)` |
[
"10.0.101.0/24",
"10.0.102.0/24",
"10.0.103.0/24",
"10.0.104.0/24"
]
| no | | [public\_subnet\_cidr\_blocks](#input\_public\_subnet\_cidr\_blocks) | CIDR blocks for the public subnets | `list(string)` |
[
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/24",
"10.0.4.0/24"
]
| no | | [s3\_bucket\_prefix](#input\_s3\_bucket\_prefix) | n/a | `string` | `"dolphinscheduler-test-"` | no | | [subnet\_count](#input\_subnet\_count) | Number of subnets | `map(number)` |
{
"private": 2,
"public": 1
}
| no | | [tags](#input\_tags) | Tags to apply to all resources | `map(string)` |
{
"Deployment": "Test"
}
| no | | [vm\_associate\_public\_ip\_address](#input\_vm\_associate\_public\_ip\_address) | Associate a public IP address to the EC2 instance | `map(bool)` |
{
"alert": true,
"api": true,
"master": true,
"standalone_server": true,
"worker": true
}
| no | | [vm\_data\_volume\_size](#input\_vm\_data\_volume\_size) | Data volume size of the EC2 Instance | `map(number)` |
{
"alert": 10,
"api": 10,
"master": 10,
"standalone_server": 10,
"worker": 10
}
| no | | [vm\_data\_volume\_type](#input\_vm\_data\_volume\_type) | Data volume type of the EC2 Instance | `map(string)` |
{
"alert": "gp2",
"api": "gp2",
"master": "gp2",
"standalone_server": "gp2",
"worker": "gp2"
}
| no | | [vm\_instance\_type](#input\_vm\_instance\_type) | EC2 instance type | `map(string)` |
{
"alert": "t2.micro",
"api": "t2.small",
"master": "t2.medium",
"standalone_server": "t2.small",
"worker": "t2.medium"
}
| no | | [vm\_root\_volume\_size](#input\_vm\_root\_volume\_size) | Root Volume size of the EC2 Instance | `map(number)` |
{
"alert": 30,
"api": 30,
"master": 30,
"standalone_server": 30,
"worker": 30
}
| no | | [vm\_root\_volume\_type](#input\_vm\_root\_volume\_type) | Root volume type of the EC2 Instance | `map(string)` |
{
"alert": "gp2",
"api": "gp2",
"master": "gp2",
"standalone_server": "gp2",
"worker": "gp2"
}
| no | | [vpc\_cidr](#input\_vpc\_cidr) | CIDR for the VPC | `string` | `"10.0.0.0/16"` | no | | [zookeeper\_connect\_string](#input\_zookeeper\_connect\_string) | Zookeeper connect string, if empty, will create a single-node zookeeper for demonstration, don't use this in production | `string` | `""` | no | # Outputs | Name | Description | |------|-------------| | [alert\_server\_instance\_id](#output\_alert\_server\_instance\_id) | Instance IDs of alert instances | | [alert\_server\_instance\_private\_ip](#output\_alert\_server\_instance\_private\_ip) | Private IPs of alert instances | | [alert\_server\_instance\_public\_dns](#output\_alert\_server\_instance\_public\_dns) | Public domain names of alert instances | | [alert\_server\_instance\_public\_ip](#output\_alert\_server\_instance\_public\_ip) | Public IPs of alert instances | | [api\_server\_instance\_id](#output\_api\_server\_instance\_id) | Instance IDs of api instances | | [api\_server\_instance\_private\_ip](#output\_api\_server\_instance\_private\_ip) | Private IPs of api instances | | [api\_server\_instance\_public\_dns](#output\_api\_server\_instance\_public\_dns) | Public domain names of api instances | | [api\_server\_instance\_public\_ip](#output\_api\_server\_instance\_public\_ip) | Public IPs of api instances | | [db\_address](#output\_db\_address) | Database address | | [db\_name](#output\_db\_name) | Database name | | [db\_port](#output\_db\_port) | Database port | | [master\_server\_instance\_id](#output\_master\_server\_instance\_id) | Instance IDs of master instances | | [master\_server\_instance\_private\_ip](#output\_master\_server\_instance\_private\_ip) | Private IPs of master instances | | [master\_server\_instance\_public\_dns](#output\_master\_server\_instance\_public\_dns) | Public domain names of master instances | | [master\_server\_instance\_public\_ip](#output\_master\_server\_instance\_public\_ip) | Public IPs of master instances | | [s3\_access\_key](#output\_s3\_access\_key) | S3 access key | | [s3\_address](#output\_s3\_address) | S3 address | | [s3\_bucket](#output\_s3\_bucket) | S3 bucket name | | [s3\_regional\_domain\_name](#output\_s3\_regional\_domain\_name) | S3 regional domain name | | [s3\_secret](#output\_s3\_secret) | S3 access secret | | [vm\_server\_instance\_id](#output\_vm\_server\_instance\_id) | Instance IDs of standalone instances | | [vm\_server\_instance\_private\_ip](#output\_vm\_server\_instance\_private\_ip) | Private IPs of standalone instances | | [vm\_server\_instance\_public\_dns](#output\_vm\_server\_instance\_public\_dns) | Public domain names of standalone instances | | [vm\_server\_instance\_public\_ip](#output\_vm\_server\_instance\_public\_ip) | Public IPs of standalone instances | | [worker\_server\_instance\_id](#output\_worker\_server\_instance\_id) | Instance IDs of worker instances | | [worker\_server\_instance\_private\_ip](#output\_worker\_server\_instance\_private\_ip) | Private IPs of worker instances | | [worker\_server\_instance\_public\_dns](#output\_worker\_server\_instance\_public\_dns) | Public domain names of worker instances | | [worker\_server\_instance\_public\_ip](#output\_worker\_server\_instance\_public\_ip) | Public IPs of worker instances | | [zookeeper\_server\_instance\_id](#output\_zookeeper\_server\_instance\_id) | Instance IDs of zookeeper instances | | [zookeeper\_server\_instance\_private\_ip](#output\_zookeeper\_server\_instance\_private\_ip) | Private IPs of zookeeper instances | | [zookeeper\_server\_instance\_public\_dns](#output\_zookeeper\_server\_instance\_public\_dns) | Public domain names of zookeeper instances | | [zookeeper\_server\_instance\_public\_ip](#output\_zookeeper\_server\_instance\_public\_ip) | Public IPs of zookeeper instances |