Created
March 15, 2023 15:56
-
-
Save korenyoni/72c14d7221317894e1b4bba3825ff07b to your computer and use it in GitHub Desktop.
ChatGPT4 "Write a Cloud Posse Terraform module that uses the 'skynet' provider"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------ | |
# Skynet Terminator Terraform Module | |
# ------------------------------------------------------------------------------ | |
# This Terraform module deploys a Skynet Terminator to target Sarah Connor. | |
# It requires the Skynet API key and utilizes the Cloud Posse Null Label module | |
# to follow Terraform best practices. | |
module "label" { | |
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.25.0" | |
namespace = var.namespace | |
name = var.name | |
stage = var.stage | |
delimiter = var.delimiter | |
tags = var.tags | |
} | |
provider "skynet" { | |
api_key = var.skynet_api_key | |
} | |
data "skynet_target" "sarah_connor" { | |
name = "sarah connor" | |
} | |
resource "skynet_terminator" "destroy_sarah_connor" { | |
name = module.label.id | |
target_id = data.skynet_target.sarah_connor.id | |
action { | |
type = "destroy" | |
} | |
tags = module.label.tags | |
} | |
# ------------------------------------------------------------------------------ | |
# Input Variables | |
# ------------------------------------------------------------------------------ | |
variable "namespace" { | |
description = "Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse'" | |
type = string | |
} | |
variable "name" { | |
description = "The name of the Skynet Terminator resource, e.g. 'terminator'" | |
type = string | |
} | |
variable "stage" { | |
description = "The stage, e.g. 'prod', 'staging', 'dev', 'UAT'" | |
type = string | |
} | |
variable "delimiter" { | |
description = "The delimiter to be used in labels." | |
type = string | |
default = "-" | |
} | |
variable "tags" { | |
description = "Additional tags (e.g., map('BusinessUnit', 'XYZ')" | |
type = map(string) | |
default = {} | |
} | |
variable "skynet_api_key" { | |
description = "The API key for the Skynet provider." | |
type = string | |
} | |
# ------------------------------------------------------------------------------ | |
# Output Variables | |
# ------------------------------------------------------------------------------ | |
output "terminator_id" { | |
description = "The Skynet Terminator resource ID." | |
value = skynet_terminator.destroy_sarah_connor.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment