You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.6 KiB
105 lines
3.6 KiB
2 years ago
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||
|
# or more contributor license agreements. See the NOTICE file
|
||
|
# distributed with this work for additional information
|
||
|
# regarding copyright ownership. The ASF licenses this file
|
||
|
# to you under the Apache License, Version 2.0 (the
|
||
|
# "License"); you may not use this file except in compliance
|
||
|
# with the License. You may obtain a copy of the License at
|
||
|
#
|
||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||
|
#
|
||
|
# Unless required by applicable law or agreed to in writing,
|
||
|
# software distributed under the License is distributed on an
|
||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||
|
# KIND, either express or implied. See the License for the
|
||
|
# specific language governing permissions and limitations
|
||
|
# under the License.
|
||
|
|
||
|
resource "aws_security_group" "api" {
|
||
|
name = "api"
|
||
|
description = "Allow incoming connections"
|
||
|
vpc_id = aws_vpc._.id
|
||
|
ingress {
|
||
|
from_port = 12345
|
||
|
to_port = 12345
|
||
|
protocol = "tcp"
|
||
|
cidr_blocks = ["0.0.0.0/0"]
|
||
|
description = "Allow incoming HTTP connections"
|
||
|
}
|
||
|
ingress {
|
||
|
from_port = 22
|
||
|
to_port = 22
|
||
|
protocol = "tcp"
|
||
|
cidr_blocks = ["0.0.0.0/0"]
|
||
|
description = "Allow incoming SSH connections (Linux)"
|
||
|
}
|
||
|
egress {
|
||
|
from_port = 0
|
||
|
to_port = 0
|
||
|
protocol = "-1"
|
||
|
cidr_blocks = ["0.0.0.0/0"]
|
||
|
}
|
||
|
tags = merge(var.tags, {
|
||
|
"Name" = "${var.name_prefix}-sg"
|
||
|
})
|
||
|
}
|
||
|
|
||
|
data "template_file" "api_user_data" {
|
||
|
template = file("templates/cloud-init.yaml")
|
||
|
vars = {
|
||
|
"ssh_public_key" = aws_key_pair.key_pair.public_key
|
||
|
"dolphinscheduler_version" = var.ds_version
|
||
|
"dolphinscheduler_component" = "api-server"
|
||
|
"database_address" = aws_db_instance.database.address
|
||
|
"database_port" = aws_db_instance.database.port
|
||
|
"database_name" = aws_db_instance.database.db_name
|
||
|
"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
|
||
|
"s3_bucket_name" = module.s3_bucket.s3_bucket_id
|
||
|
"s3_endpoint" = ""
|
||
|
}
|
||
|
}
|
||
|
|
||
|
resource "aws_instance" "api" {
|
||
|
count = var.ds_component_replicas.api
|
||
|
|
||
|
ami = data.aws_ami.dolphinscheduler.id
|
||
|
instance_type = var.vm_instance_type.api
|
||
|
subnet_id = aws_subnet.public[0].id
|
||
|
vpc_security_group_ids = [aws_security_group.api.id]
|
||
|
source_dest_check = false
|
||
|
associate_public_ip_address = var.vm_associate_public_ip_address.api
|
||
|
|
||
|
user_data = data.template_file.api_user_data.rendered
|
||
|
|
||
|
root_block_device {
|
||
|
volume_size = var.vm_root_volume_size.api
|
||
|
volume_type = var.vm_root_volume_type.api
|
||
|
delete_on_termination = true
|
||
|
encrypted = true
|
||
|
tags = merge(var.tags, {
|
||
|
"Name" = "${var.name_prefix}-rdb-api-${count.index}"
|
||
|
})
|
||
|
}
|
||
|
|
||
|
ebs_block_device {
|
||
|
device_name = "/dev/xvda"
|
||
|
volume_size = var.vm_data_volume_size.api
|
||
|
volume_type = var.vm_data_volume_type.api
|
||
|
encrypted = true
|
||
|
delete_on_termination = true
|
||
|
tags = merge(var.tags, {
|
||
|
"Name" = "${var.name_prefix}-ebd-api-${count.index}"
|
||
|
})
|
||
|
}
|
||
|
|
||
|
tags = merge(var.tags, {
|
||
|
"Name" = "${var.name_prefix}-api-${count.index}"
|
||
|
})
|
||
|
}
|