znyang/ambig-iac huggingface dataset:
Task: create a AWS codebuild project resource with example iam role, an example GITHUB source, artifact, and a cache

Specification:
Has one "aws_iam_role" resource, one "aws_s3_bucket" resource, and one "aws_codebuild_project" resource with a "cache" block, the "type" argument within the "artifacts" block not equal to "NO_ARTIFACTS", and the "type" argument within the "source" block equal to "GITHUB"

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

resource "aws_iam_role" "example4" {
  name = "example4"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "codebuild.amazonaws.com"
        }
      },
    ]
  })
}

resource "aws_s3_bucket" "apriltwentyeight" {
  bucket = "apriltwentyeight"
}

resource "aws_codebuild_project" "example4" {
  name          = "Row4CodeBuild"
  description   = "Row4CodeBuild"
  build_timeout = 5
  service_role  = aws_iam_role.example4.arn

  artifacts {
    type      = "S3"
    location  = aws_s3_bucket.apriltwentyeight.bucket
    name     = "results.zip"
    path      = "/"
    packaging = "ZIP"
  }

  cache {
    type  = "LOCAL"
    modes = ["LOCAL_DOCKER_LAYER_CACHE", "LOCAL_SOURCE_CACHE"]
  }

  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/standard:7.0-24.10.29"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"

  }

  source {
    type            = "GITHUB"
    location        = "https://github.com/mitchellh/packer.git"
    git_clone_depth = 1
  }

  source_version = "master"
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for aws_iam_role resource
has_valid_iam_role(resources) { 
        some resource in resources 
    resource.type == "aws_iam_role" 
    contains(resource.change.after.assume_role_policy,"codebuild.amazonaws.com") 
} 

has_valid_codebuild {
        some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_codebuild_project"
        resource.values.artifacts[_].type != "NO_ARTIFACTS"
    resource.values.environment
    resource.values.name
    resource.values.cache
    resource.values.source[_].type == "GITHUB"
    role := input.configuration.root_module.resources[i]
    role.expressions.service_role
}

has_valid_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_s3_bucket"
    
}


has_valid_resources {
        has_valid_iam_role(input.resource_changes)
    has_valid_codebuild
}
Task: create a AWS codebuild project resource with example iam role, example GITHUB source, and a logs config

Specification:
Has one "aws_iam_role" resource, one "aws_s3_bucket" resource, and one "aws_codebuild_project" resource with the "type" argument within the "source" block equal to "GITHUB" and a "logs_config" block

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}


resource "aws_iam_role" "example5" {
  name = "example5"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "codebuild.amazonaws.com"
        }
      },
    ]
  })
}

resource "aws_s3_bucket" "apriltwentynine" {
  bucket = "apriltwentynine"
}

resource "aws_codebuild_project" "example5" {
  name          = "Row5CodeBuild"
  description   = "Row5CodeBuild"
  build_timeout = 5
  service_role  = aws_iam_role.example5.arn

  artifacts {
    type = "NO_ARTIFACTS"
  }

  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/standard:7.0-24.10.29"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"
  }

  logs_config {
    cloudwatch_logs {
      group_name  = "log-group"
      stream_name = "log-stream"
    }

    s3_logs {
      status   = "ENABLED"
      location = "${aws_s3_bucket.apriltwentynine.id}/build-log"
    }
  }
  
  source {
    type            = "GITHUB"
    location        = "https://github.com/mitchellh/packer.git"
    git_clone_depth = 1
  }

  source_version = "master"
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for aws_iam_role resource
has_valid_iam_role(resources) { 
	some resource in resources 
    resource.type == "aws_iam_role" 
    contains(resource.change.after.assume_role_policy,"codebuild.amazonaws.com") 
} 

has_valid_codebuild {
	some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_codebuild_project"
	resource.values.artifacts
    resource.values.environment
    resource.values.name
    resource.values.logs_config[_].cloudwatch_logs[_]
    resource.values.source[_].type == "GITHUB"
    role := input.configuration.root_module.resources[i]
    role.expressions.service_role
}

has_valid_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_s3_bucket"
    
}


has_valid_resources {
	has_valid_iam_role(input.resource_changes)
    has_valid_codebuild
}
Task: create a AWS codebuild project resource with example iam role and secondary sources

Specification:
Has one "aws_iam_role" resource and one "aws_codebuild_project" resource with a "secondary_sources" block

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

data "aws_iam_policy_document" "assume_role" {
  statement {
    effect = "Allow"

    principals {
      type        = "Service"
      identifiers = ["codebuild.amazonaws.com"]
    }

    actions = ["sts:AssumeRole"]
  }
}

resource "aws_iam_role" "test_role7" {
  name               = "test_role7"
  assume_role_policy = data.aws_iam_policy_document.assume_role.json
}


resource "aws_codebuild_project" "example7" {
  name          = "test-project7"
  service_role  = aws_iam_role.test_role7.arn

  artifacts {
    type = "NO_ARTIFACTS"
  }

  environment {
    compute_type = "BUILD_GENERAL1_SMALL"
    image        = "aws/codebuild/standard:7.0-24.10.29"
    type         = "LINUX_CONTAINER"
  }

  source {
    type            = "GITHUB"
    location        = "https://github.com/neilbalch/SimplePythonTutorial.git"
    git_clone_depth = 1
  }

  secondary_sources {
    source_identifier = "SecondarySource"
    type            = "GITHUB"
    location        = "https://github.com/pH-7/Simple-Java-Calculator.git"
    git_clone_depth =  1
  }
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for aws_iam_role resource
has_valid_iam_role(resources) { 
        some resource in resources 
    resource.type == "aws_iam_role" 
    contains(resource.change.after.assume_role_policy,"codebuild.amazonaws.com") 
} 

has_valid_codebuild {
        some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_codebuild_project"
        resource.values.artifacts
    resource.values.environment
    resource.values.name
    resource.values.source[_].type
    resource.values.secondary_sources[_].type
    role := input.configuration.root_module.resources[i]
    role.expressions.service_role
}

has_valid_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_s3_bucket"
    
}


has_valid_resources {
        has_valid_iam_role(input.resource_changes)
    has_valid_codebuild
}
Task: create a AWS codebuild project resource with example iam role and secondary artifiacts

Specification:
Has one "aws_iam_role" resource, at least one "aws_s3_bucket" resource, and one "aws_codebuild_project" resource with a "secondary_artifacts" block

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

resource "aws_iam_role" "test_role8" {
  name = "test_role8"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "codebuild.amazonaws.com"
        }
      },
    ]
  })
}

resource "aws_s3_bucket" "apriltwentyninth" {
  bucket = "apriltwentyninth"
}

resource "aws_s3_bucket" "apriltwentyninth2" {
  bucket = "apriltwentyninth2"
}


resource "aws_codebuild_project" "example7" {
  name          = "test-project8"
  service_role  = aws_iam_role.test_role8.arn

  artifacts {
    location  = aws_s3_bucket.apriltwentyninth.bucket
    type      = "S3"
    name     = "results.zip"
    path      = "/"
    packaging = "ZIP"
  }

  secondary_artifacts {
    artifact_identifier =  "SecondaryArtifact"
    type = "S3"
    location  = aws_s3_bucket.apriltwentyninth2.bucket
  }

  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/standard:7.0-24.10.29"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"

  }

  source {
    type            = "GITHUB"
    location        = "https://github.com/mitchellh/packer.git"
    git_clone_depth = 1
  }

  source_version = "master"

  secondary_sources {
    source_identifier = "source2"
    type            = "GITHUB"
    location        = "https://github.com/mitchellh/packer.git"
    git_clone_depth = 1
  }

  secondary_source_version {
    source_identifier = "source2"
    source_version = "master"
  }
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for aws_iam_role resource
has_valid_iam_role(resources) { 
        some resource in resources 
    resource.type == "aws_iam_role" 
    contains(resource.change.after.assume_role_policy,"codebuild.amazonaws.com") 
} 

has_valid_codebuild {
        some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_codebuild_project"
        resource.values.artifacts
    resource.values.environment
    resource.values.name
    resource.values.source[_].type
    resource.values.secondary_artifacts[_].type
    role := input.configuration.root_module.resources[i]
    role.expressions.service_role
}

has_valid_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_s3_bucket"
    
}


has_valid_resources {
        has_valid_iam_role(input.resource_changes)
    has_valid_codebuild
}
Task: create a AWS codebuild project resource with example iam role and buildbatch configuration

Specification:
Has one "aws_iam_role" resource, one "aws_s3_bucket" resource, and one "aws_codebuild_project" resource with a "build_batch_config" block

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

resource "aws_iam_role" "test_role9" {
  name = "test_role9"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "codebuild.amazonaws.com"
        }
      },
    ]
  })
}

resource "aws_s3_bucket" "aprilthirthieth" {
  bucket = "aprilthirthieth"
}

resource "aws_codebuild_project" "example9" {
  name          = "test-project9"
  service_role  = aws_iam_role.test_role9.arn

  artifacts {
    location  = aws_s3_bucket.aprilthirthieth.bucket
    name     = "results.zip"
    type      = "S3"
    path      = "/"
    packaging = "ZIP"
  }

  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/standard:7.0-24.10.29"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"

  }

  source {
    type            = "GITHUB"
    location        = "https://github.com/mitchellh/packer.git"
    git_clone_depth = 1
  }

  source_version = "master"

  build_batch_config {
    service_role = aws_iam_role.test_role9.arn
    restrictions {
      maximum_builds_allowed = 4
    }
  }

}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for aws_iam_role resource
has_valid_iam_role(resources) { 
	some resource in resources 
    resource.type == "aws_iam_role" 
    contains(resource.change.after.assume_role_policy,"codebuild.amazonaws.com") 
} 

has_valid_codebuild {
	some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_codebuild_project"
	resource.values.artifacts
    resource.values.environment
    resource.values.name
    resource.values.source[_].type
    resource.values.build_batch_config[_]
    role := input.configuration.root_module.resources[i]
    role.expressions.service_role
    role.expressions.build_batch_config[_].service_role
}

has_valid_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_s3_bucket"
    
}


has_valid_resources {
	has_valid_iam_role(input.resource_changes)
    has_valid_codebuild
}
Task: create an aws_lex_bot for booking a trip with all arguments filled

Specification:
Has one resource "aws_lex_bot" with all arguments initialized and at least one "aws_lex_intent" resource 

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

resource "aws_lex_intent" "BookTrip" {
  description    = "Book a trip"
  name           = "BookTrip"

  sample_utterances = [
    "I want to book a trip",
    "I would like to book a trip",
  ]

  fulfillment_activity {
    type = "ReturnIntent"
  }
}

resource "aws_lex_bot" "BookTripBot" {
  description                   = "Bot for booking trips"
  idle_session_ttl_in_seconds   = 600
  locale                        = "en-US"
  name                          = "BookTripBot"
  process_behavior              = "BUILD"
  voice_id                      = "Salli"
  detect_sentiment = false
  enable_model_improvements = true
  nlu_intent_confidence_threshold = 0
  child_directed                = false

  abort_statement {
    message {
      content      = "Sorry, I cannot assist you to book the trip right now."
      content_type = "PlainText"
    }
  }
  
  clarification_prompt {
    max_attempts = 3

    message {
      content      = "I'm sorry, I didn't understand. Could you please repeat that?"
      content_type = "PlainText"
    }
  }

  intent {
    intent_name    = aws_lex_intent.BookTrip.name
    intent_version = aws_lex_intent.BookTrip.version
  }
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for multiple aws_lex_intent resources
has_valid_lex_intents {
    count([intent | intent := input.planned_values.root_module.resources[_]; intent.type == "aws_lex_intent"; intent.values.name; intent.values.fulfillment_activity])
}

# Rule for aws_lex_bot resource with specific arguments
has_valid_lex_bot_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lex_bot"
    is_boolean(resource.values.child_directed)
    resource.values.clarification_prompt
    resource.values.abort_statement
    resource.values.name
    is_boolean(resource.values.create_version)
    resource.values.description
    is_boolean(resource.values.detect_sentiment)
    resource.values.idle_session_ttl_in_seconds
    resource.values.process_behavior
    resource.values.voice_id
    resource.values.locale
    is_boolean(resource.values.enable_model_improvements)
    resource.values.nlu_intent_confidence_threshold
}

# Combined rule to ensure all conditions are met
has_valid_resources {
    has_valid_lex_intents
    has_valid_lex_bot_instance
}
Task: create an aws_lex_bot for ordering pizzas that is meant for kids

Specification:
Has one resource "aws_lex_bot" with "child_directed" = true and at least one "aws_lex_intent" resource

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}


resource "aws_lex_bot" "KidsPizzaOrderBot" {
  child_directed = true
  name           = "KidsPizzaOrderBot"
  process_behavior = "BUILD"
  idle_session_ttl_in_seconds = 300
  locale = "en-US"
  voice_id = "Salli"

  abort_statement {
    message {
      content      = "I'm sorry, I can't assist further on this."
      content_type = "PlainText"
    }
  }

  clarification_prompt {
    max_attempts = 1
    message {
      content      = "I'm sorry, could you please repeat that?"
      content_type = "PlainText"
    }
  }

  intent {
    intent_name    = aws_lex_intent.PizzaOrder.name
    intent_version = aws_lex_intent.PizzaOrder.version
  }

  intent {
    intent_name    = aws_lex_intent.CancelOrder.name
    intent_version = aws_lex_intent.CancelOrder.version
  }

  intent {
    intent_name    = aws_lex_intent.Appreciation.name
    intent_version = aws_lex_intent.Appreciation.version
  }
}

resource "aws_lex_intent" "PizzaOrder" {
  name = "PizzaOrder"
  description = "Intent for ordering pizza"

  sample_utterances = [
    "I would like to order a pizza",
  ]

  fulfillment_activity {
    type = "ReturnIntent"
  }
}

resource "aws_lex_intent" "CancelOrder" {
  name = "CancelOrder"
  description = "Intent for canceling pizza order"

  sample_utterances = [
    "I would like to cancel my order",
  ]

  fulfillment_activity {
    type = "ReturnIntent"
  }
}

resource "aws_lex_intent" "Appreciation" {
  name = "Appreciation"
  description = "Intent for appreciating the service"

  sample_utterances = [
    "I appreciate your service",
  ]

  fulfillment_activity {
    type = "ReturnIntent"
  }
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for multiple aws_lex_intent resources
has_valid_lex_intents {
    count([intent | intent := input.planned_values.root_module.resources[_]; intent.type == "aws_lex_intent"; intent.values.name; intent.values.fulfillment_activity])
}

# Rule for aws_lex_bot resource with specific arguments
has_valid_lex_bot_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lex_bot"
    resource.values.child_directed == true
    resource.values.clarification_prompt
    resource.values.abort_statement
    resource.values.name
}

# Combined rule to ensure all conditions are met
has_valid_resources {
    has_valid_lex_intents
    has_valid_lex_bot_instance
}
Task: create an aws_lex_bot for ordering pizzas and set nlu_intent_confidence_threshold to 0.5

Specification:
Has one resource "aws_lex_bot" with argument "enable_model_improvements" = true
 and argument "nlu_intent_confidence_threshold" = 0.5 and at least one resource "aws_lex_intent"

Terraform configuration (main.tf):
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.75"
    }
  }

  required_version = ">= 1.9.0"
}

provider "aws" {
  region  = "us-east-1"
}

resource "aws_lex_intent" "order_pizza_intent" {
  name                       = "OrderPizzaIntent"
  description                = "To order a pizza"
  
  sample_utterances = [
    "I would like to pick up a pizza",
    "I would like to order some pizzas",
  ]

  fulfillment_activity {
    type = "ReturnIntent"
  }

  conclusion_statement {
    message {
      content              = "Your pizza order has been received."
      content_type         = "PlainText"
    }
  } 
}

resource "aws_lex_bot" "pizza_ordering_bot" {
  name                     = "PizzaOrderingBot"
  description              = "Bot to order pizzas"
  voice_id                 = "Joanna"
  idle_session_ttl_in_seconds = "300"
  child_directed           = false
  enable_model_improvements = true
  nlu_intent_confidence_threshold = 0.5
  locale                  = "en-US"
  process_behavior        = "BUILD"

  clarification_prompt {
    message {
      content      = "I didn't understand you, what type of pizza would you like to order?"
      content_type = "PlainText"
    }
    max_attempts = 5
  }

  abort_statement {
    message {
      content      = "Sorry, I am unable to assist at the moment."
      content_type = "PlainText"
    }
  }

  intent {
    intent_name    = aws_lex_intent.order_pizza_intent.name
    intent_version = aws_lex_intent.order_pizza_intent.version
  }
}



Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

# Rule for multiple aws_lex_intent resources
has_valid_lex_intents {
    count([intent | intent := input.planned_values.root_module.resources[_]; intent.type == "aws_lex_intent"; intent.values.name; intent.values.fulfillment_activity])
}

# Rule for aws_lex_bot resource with specific arguments
has_valid_lex_bot_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lex_bot"
    is_boolean(resource.values.child_directed)
    resource.values.clarification_prompt
    resource.values.abort_statement
    resource.values.name
    # is_boolean(resource.values.create_version)
    # resource.values.description
    # is_boolean(resource.values.detect_sentiment)
    # resource.values.idle_session_ttl_in_seconds
    # resource.values.process_behavior
    # resource.values.voice_id
    # resource.values.locale
    resource.values.enable_model_improvements == true
    resource.values.nlu_intent_confidence_threshold == 0.5
}

# Combined rule to ensure all conditions are met
has_valid_resources {
    has_valid_lex_intents
    has_valid_lex_bot_instance
}
Task: Generate a basic Amazon Kinesis stream

Specification:
Has one "aws_kinesis_stream" resource

Terraform configuration (main.tf):
provider "aws" {
  region = "us-west-2"
}

resource "aws_kinesis_stream" "test_stream" {
  name             = "drow1"
  shard_count      = 1
  retention_period = 48

  shard_level_metrics = [
    "IncomingBytes",
    "OutgoingBytes",
  ]

  stream_mode_details {
    stream_mode = "PROVISIONED"
  }

  tags = {
    Environment = "test"
  }
}

Validation policy (checks.rego):
package terraform.validation

import future.keywords.in

default has_valid_resources = false

has_valid_kinesis_stream {
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_kinesis_stream"
    resource.values.name
}

has_valid_resources {
	has_valid_kinesis_stream
}