variable "some_var" {
    default = 12
}

resource "something" "nice" {
  name        = "hello"
  value       = var.some_var
  x           = var.some_var > 5 ? var.some_var : 10
  cidr_blocks = [
    for num in [1,2,3]:
    cidrhost("10.0.0.0/24", num)
  ]

  str = <<-EOT
    hello
    world
  EOT

  /*
    Multiline comment
  */

  # Single comment
  dynamic "setting" {
    for_each = var.settings
    content {
      namespace = setting.value["namespace"]
      name = setting.value["name"]
      value = setting.value["value"]
    }
  }
}

resource "other" "resource" {
  count = 3
  name = "resource${count.index+1}"
}

# #988 'Dot in string breaks highlighting in Terraform'
resource "aws_s3_bucket" "this" {
  bucket = "my-tf-test-bucket"
  website {
    index_document = "index.html"
    error_document = "error.html"
  }
}

# An IAM Policy Document that has a parameter 'variable' that overlaps with the variable class
# variable = below should be variable (text) = (punctuation). variable above should be NameReserved
data "aws_iam_policy_document" "example" {
  statement {
    sid = "1"
    actions = [
      "s3:ListAllMyBuckets",
      "s3:GetBucketLocation",
    ]
    resources = [
      "arn:aws:s3:::*",
    ]
  }
  statement {
    actions = [
      "s3:ListBucket",
    ]
    resources = [
      "arn:aws:s3:::${var.s3_bucket_name}",
    ]
    condition {
      test     = "StringLike"
      variable = "s3:prefix"
      values = [
        "",
        "home/",
        "home/&{aws:username}/",
      ]
    }
  }
  statement {
    actions = [
      "s3:*",
    ]
    resources = [
      "arn:aws:s3:::${var.s3_bucket_name}/home/&{aws:username}",
      "arn:aws:s3:::${var.s3_bucket_name}/home/&{aws:username}/*",
    ]
  }
}

# the _ in default_tags gets identified as `err` and shouldn't
provider "aws" {
  default_tags {
    tags = {
      name = "My Awesome AWS Environment"
      environment = var.app.environment
      application = var.app.name
      owner       = var.app.owner
      contact     = var.app.contact
    }
  }
}

# name here is NameAttribute
resource "aws_lb" "web" {
	name = "my fancy lb"
	port = 80
}

# The first name is NameAttribute the second is not
resource "aws_s3_bucket" "my_bucket" {
	name = var.name

}

# type, description, default are all NameAttribute
variable "my_variable" {
	type = number
	description = "The port the application listens on"
	default = 80
}
