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 7256a0f  Add support for extra tags on all resources (#6)
7256a0f is described below

commit 7256a0fc64a56330074ed89eadea31f07561afe0
Author: Rahul Bajaj <rahulrb0...@gmail.com>
AuthorDate: Sat Jun 10 23:47:01 2023 -0400

    Add support for extra tags on all resources (#6)
---
 aws/ec2.tf       | 13 +++++++++----
 aws/variables.tf |  6 ++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/aws/ec2.tf b/aws/ec2.tf
index a7a1bb9..199eb56 100644
--- a/aws/ec2.tf
+++ b/aws/ec2.tf
@@ -20,10 +20,13 @@ provider "aws" {
 resource "aws_instance" "skywalking" {
   ami = var.ami
   instance_type = var.instance_type
-  tags = {
-    Name = "skywalking-terraform"
-    Description = "Installing and configuring Skywalking on AWS"
-  }
+  tags = merge(
+    {
+      Name = "skywalking-terraform"
+      Description = "Installing and configuring Skywalking on AWS"
+    },
+    var.extra_tags
+  )
   key_name = aws_key_pair.ssh-user.id
   vpc_security_group_ids = [ aws_security_group.ssh-access.id ]
 }
@@ -44,10 +47,12 @@ resource "aws_security_group" "ssh-access" {
       self            = false
     }
   ]
+  tags = var.extra_tags
 }
 
 resource "aws_key_pair" "ssh-user" {
     public_key = file(var.public_key_path)
+    tags = var.extra_tags
 }
 
 resource "local_file" "write_to_host_file" {
diff --git a/aws/variables.tf b/aws/variables.tf
index ce1f968..aee7abb 100644
--- a/aws/variables.tf
+++ b/aws/variables.tf
@@ -36,3 +36,9 @@ variable "public_key_path" {
   description = "Path to the public key file"
   default     = "~/.ssh/skywalking-terraform.pub"
 }
+
+variable "extra_tags" {
+  description = "Additional tags to be added to all resources"
+  type        = map(string)
+  default     = {}
+}

Reply via email to