This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-terraform.git
The following commit(s) were added to refs/heads/main by this push:
new dca78fa Add option to create multiple OAP and UI servers on AWS (#8)
dca78fa is described below
commit dca78fa254509d7df4ef884f11f0fb534f34fc77
Author: Rahul Bajaj <[email protected]>
AuthorDate: Sat Jun 17 01:59:38 2023 -0400
Add option to create multiple OAP and UI servers on AWS (#8)
---
aws/ec2.tf | 43 +++++++++++++++++++++++++++++++++++++------
aws/variables.tf | 10 ++++++++++
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/aws/ec2.tf b/aws/ec2.tf
index 199eb56..dfd135c 100644
--- a/aws/ec2.tf
+++ b/aws/ec2.tf
@@ -17,13 +17,29 @@ provider "aws" {
region = var.region
}
-resource "aws_instance" "skywalking" {
+resource "aws_instance" "skywalking-oap" {
+ count = var.oap_instance_count
ami = var.ami
instance_type = var.instance_type
tags = merge(
{
- Name = "skywalking-terraform"
- Description = "Installing and configuring Skywalking on AWS"
+ Name = "skywalking-oap"
+ Description = "Installing and configuring Skywalking OAPService on AWS"
+ },
+ var.extra_tags
+ )
+ key_name = aws_key_pair.ssh-user.id
+ vpc_security_group_ids = [ aws_security_group.ssh-access.id ]
+}
+
+resource "aws_instance" "skywalking-ui" {
+ count = var.ui_instance_count
+ ami = var.ami
+ instance_type = var.instance_type
+ tags = merge(
+ {
+ Name = "skywalking-ui"
+ Description = "Installing and configuring Skywalking UI on AWS"
},
var.extra_tags
)
@@ -55,7 +71,22 @@ resource "aws_key_pair" "ssh-user" {
tags = var.extra_tags
}
-resource "local_file" "write_to_host_file" {
- content = "[skywalking-machine]\n${aws_instance.skywalking.public_ip}"
- filename = "${path.module}/../ansible/inventory/hosts"
+resource "local_file" "oap_instance_ips" {
+ count = var.oap_instance_count
+ content = join("\n", flatten([
+ ["[skywalking-oap]"],
+ aws_instance.skywalking-oap.*.public_ip,
+ [""] # Adds an empty string for the trailing newline
+ ]))
+ filename = "${path.module}/../ansible/inventory/oap-server"
+}
+
+resource "local_file" "ui_instance_ips" {
+ count = var.ui_instance_count
+ content = join("\n", flatten([
+ ["[skywalking-ui]"],
+ aws_instance.skywalking-ui.*.public_ip,
+ [""] # Adds an empty string for the trailing newline
+ ]))
+ filename = "${path.module}/../ansible/inventory/ui-server"
}
diff --git a/aws/variables.tf b/aws/variables.tf
index aee7abb..1717eb4 100644
--- a/aws/variables.tf
+++ b/aws/variables.tf
@@ -13,6 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+variable "oap_instance_count" {
+ type = number
+ default = 1
+}
+
+variable "ui_instance_count" {
+ type = number
+ default = 1
+}
+
variable "region" {
type = string
description = "Physical location for clustered data centers."