From 44bfad24a1a7cd5ce9093926f85f22cca8386f7f Mon Sep 17 00:00:00 2001 From: "scott.eppler" Date: Tue, 6 Oct 2020 10:43:13 -0500 Subject: [PATCH] Add Terraform example file for Syntax Highlighting --- .../highlighted/Terraform/main.tf | 48 +++++++++++++++++++ tests/syntax-tests/source/Terraform/main.tf | 48 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/syntax-tests/highlighted/Terraform/main.tf create mode 100644 tests/syntax-tests/source/Terraform/main.tf diff --git a/tests/syntax-tests/highlighted/Terraform/main.tf b/tests/syntax-tests/highlighted/Terraform/main.tf new file mode 100644 index 00000000..80fb6a92 --- /dev/null +++ b/tests/syntax-tests/highlighted/Terraform/main.tf @@ -0,0 +1,48 @@ +provider "github" { + organization = var.github_organization +} + +resource "tls_private_key" "deploy_key" { + algorithm = "RSA" + rsa_bits = "4096" +} + +resource "null_resource" "private_key_file" { + triggers = { + deploy_key = tls_private_key.deploy_key.private_key_pem + } + + provisioner "file" { + content = tls_private_key.deploy_key.private_key_pem + destination = "~/${var.repo_name}_deploy_key.pem" + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } + + provisioner "remote-exec" { + inline = [ + "sudo mv ~/${var.repo_name}_deploy_key.pem /app/ssh_keys/", + "sudo chmod 0400 /app/ssh_keys/${var.repo_name}_deploy_key.pem", + "sudo chown app:app /app/ssh_keys/${var.repo_name}_deploy_key.pem", + ] + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } +} + +resource "github_repository_deploy_key" "repo_deploy_key" { + title = "${var.env_name} Deploy Key" + repository = var.repo_name + key = tls_private_key.deploy_key.public_key_openssh + read_only = var.read_only +} diff --git a/tests/syntax-tests/source/Terraform/main.tf b/tests/syntax-tests/source/Terraform/main.tf new file mode 100644 index 00000000..2ff02b2c --- /dev/null +++ b/tests/syntax-tests/source/Terraform/main.tf @@ -0,0 +1,48 @@ +provider "github" { + organization = var.github_organization +} + +resource "tls_private_key" "deploy_key" { + algorithm = "RSA" + rsa_bits = "4096" +} + +resource "null_resource" "private_key_file" { + triggers = { + deploy_key = tls_private_key.deploy_key.private_key_pem + } + + provisioner "file" { + content = tls_private_key.deploy_key.private_key_pem + destination = "~/${var.repo_name}_deploy_key.pem" + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } + + provisioner "remote-exec" { + inline = [ + "sudo mv ~/${var.repo_name}_deploy_key.pem /app/ssh_keys/", + "sudo chmod 0400 /app/ssh_keys/${var.repo_name}_deploy_key.pem", + "sudo chown app:app /app/ssh_keys/${var.repo_name}_deploy_key.pem", + ] + + connection { + type = "ssh" + user = "centos" + private_key = var.terraform_ssh_key + host = var.server_ip + } + } +} + +resource "github_repository_deploy_key" "repo_deploy_key" { + title = "${var.env_name} Deploy Key" + repository = var.repo_name + key = tls_private_key.deploy_key.public_key_openssh + read_only = var.read_only +}