Guest User

Untitled

a guest
Apr 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. data "aws_vpc" "vpc_name" {
  2. filter {
  3. name = "tag:Name"
  4. values = ["${var.vpc_level}-VPC"]
  5. }
  6. }
  7.  
  8. data "aws_subnet_ids" "selected" {
  9. vpc_id = "${data.aws_vpc.vpc_name.id}"
  10.  
  11. tags {
  12. Name = "*-${var.subnet_type}-*"
  13. }
  14. }
  15.  
  16. resource "random_shuffle" "subnet" {
  17. input = ["${data.aws_subnet_ids.selected.ids}"]
  18. result_count = 1
  19. }
  20.  
  21. resource "aws_instance" "instance" {
  22. ami = "${var.ami}"
  23. instance_type = "${var.instance_type}"
  24. vpc_security_group_ids = ["${var.security_group_id}"]
  25. key_name = "${var.key_name}"
  26. associate_public_ip_address = "${var.assoc_public_ip}"
  27. subnet_id = "${var.user_specified_subnet_id != "BadValue" ? var.user_specified_subnet_id : random_shuffle.subnet.result[0]}"
  28. user_data = "${file("${var.user_data_script}")}"
  29. iam_instance_profile = "${var.instance_role}"
  30.  
  31. tags {
  32. "Name" = "${var.Name}"
  33. "info:TaggingVersion" = "${var.infoTaggingVersion}"
  34. "its:Provisioner" = "${var.itsProvisioner}"
  35. "its:DataClassification" = "${var.itsDataClassification}"
  36. "its:ServiceOwner" = "${var.itsServiceOwner}"
  37. "its:SecurityReviewDate" = "${var.itsSecurityReviewDate}"
  38. "its:SecurityReviewTicket" = "${var.itsSecurityReviewTicket}"
  39. "CA001" = "${var.CA001}"
  40. "CostCenter" = "${var.CostCenter}"
  41. "Creator" = "${var.Creator}"
  42. "Department" = "${var.Department}"
  43. "Environment" = "${var.Environment}"
  44. "Owner" = "${var.Owner}"
  45. "Project" = "${var.Project}"
  46. "Purpose" = "${var.Purpose}"
  47. "Service" = "${var.Service}"
  48.  
  49. ### Optional tags
  50. "Application" = "${var.Application}"
  51. "Company" = "${var.Company}"
  52. "its:BackupSchedule" = "${var.itsBackupSchedule}"
  53. "its:BuildID" = "${var.itsBuildID}"
  54. "its:CmdbMapping" = "${var.itsCmdbMapping}"
  55. "CA002" = "${var.CA002}"
  56. "CA003" = "${var.CA003}"
  57. "its:OperationalHours" = "${var.itsOperationalHours}"
  58. "Role" = "${var.Role}"
  59. "Status" = "${var.Status}"
  60. "Use" = "${var.Use}"
  61. }
  62. }
Add Comment
Please, Sign In to add comment