Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data "aws_vpc" "vpc_name" {
- filter {
- name = "tag:Name"
- values = ["${var.vpc_level}-VPC"]
- }
- }
- data "aws_subnet_ids" "selected" {
- vpc_id = "${data.aws_vpc.vpc_name.id}"
- tags {
- Name = "*-${var.subnet_type}-*"
- }
- }
- resource "random_shuffle" "subnet" {
- input = ["${data.aws_subnet_ids.selected.ids}"]
- result_count = 1
- }
- resource "aws_instance" "instance" {
- ami = "${var.ami}"
- instance_type = "${var.instance_type}"
- vpc_security_group_ids = ["${var.security_group_id}"]
- key_name = "${var.key_name}"
- associate_public_ip_address = "${var.assoc_public_ip}"
- subnet_id = "${var.user_specified_subnet_id != "BadValue" ? var.user_specified_subnet_id : random_shuffle.subnet.result[0]}"
- user_data = "${file("${var.user_data_script}")}"
- iam_instance_profile = "${var.instance_role}"
- tags {
- "Name" = "${var.Name}"
- "info:TaggingVersion" = "${var.infoTaggingVersion}"
- "its:Provisioner" = "${var.itsProvisioner}"
- "its:DataClassification" = "${var.itsDataClassification}"
- "its:ServiceOwner" = "${var.itsServiceOwner}"
- "its:SecurityReviewDate" = "${var.itsSecurityReviewDate}"
- "its:SecurityReviewTicket" = "${var.itsSecurityReviewTicket}"
- "CA001" = "${var.CA001}"
- "CostCenter" = "${var.CostCenter}"
- "Creator" = "${var.Creator}"
- "Department" = "${var.Department}"
- "Environment" = "${var.Environment}"
- "Owner" = "${var.Owner}"
- "Project" = "${var.Project}"
- "Purpose" = "${var.Purpose}"
- "Service" = "${var.Service}"
- ### Optional tags
- "Application" = "${var.Application}"
- "Company" = "${var.Company}"
- "its:BackupSchedule" = "${var.itsBackupSchedule}"
- "its:BuildID" = "${var.itsBuildID}"
- "its:CmdbMapping" = "${var.itsCmdbMapping}"
- "CA002" = "${var.CA002}"
- "CA003" = "${var.CA003}"
- "its:OperationalHours" = "${var.itsOperationalHours}"
- "Role" = "${var.Role}"
- "Status" = "${var.Status}"
- "Use" = "${var.Use}"
- }
- }
Add Comment
Please, Sign In to add comment