aws policy terraform code example

Example 1: aws instance creation using terraform

resource "aws_instance" "myec2" {
  ami                    = "<AMI-ID>"
  instance_type          = "t2.micro"
  vpc_security_group_ids = ["SECURITY-GROUP-ID"]
  key_name               = "<KEY-NAME>"
  subnet_id              = "<SUBNET ID>"
  iam_instance_profile = "<ROLE NAME>"

  tags = {
    Name = "<PUT THE NAME>"
  }
}

Example 2: terraform filter_policy sample

resource "aws_sns_topic_subscription" "sns-topic" {
  topic_arn = "arn:aws:sns:${var.region}:${var.account_number}:${var.sns_topic_name}"
  protocol  = "sqs"
  endpoint  = "${aws_sqs_queue.sqs-queue.arn}"

  filter_policy = <<EOF
  {
    "key": [{"prefix":"${var.prefix_filter}"}]
  }
  EOF
}