znyang/ambig-iac huggingface dataset:
Task: create Amazon Lightsail with static ipv4 IP

Specification:
have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument

has one "aws_lightsail_static_ip" resource
    with "name" argument

has one "aws_lightsail_static_ip_attachment" resource
    with "static_ip_name" argument
    with "instance_name" argument

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

resource "aws_lightsail_static_ip_attachment" "test" {
  static_ip_name = aws_lightsail_static_ip.test.id
  instance_name  = aws_lightsail_instance.test.id
}

resource "aws_lightsail_static_ip" "test" {
  name = "example"
}

resource "aws_lightsail_instance" "test" {
  name              = "custom_gitlab"
  availability_zone = "us-east-1b"
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_2_0"
}

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

default has_required_resources = false

# Rule for aws_lightsail_instance resource
has_lightsail_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_instance"
    resource.values.name
    resource.values.availability_zone
    resource.values.blueprint_id
    resource.values.bundle_id
}

# Rule for aws_lightsail_static_ip resource
has_lightsail_static_ip {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_static_ip"
    resource.values.name
}

# Rule for aws_lightsail_static_ip_attachment resource considering expressions
has_lightsail_static_ip_attachment {
    some i
    resource := input.configuration.root_module.resources[i]
    resource.type == "aws_lightsail_static_ip_attachment"
    static_ip_name_exists(resource)
    instance_name_exists(resource)
}

static_ip_name_exists(resource) {
    resource.expressions.static_ip_name.references[_]
}

instance_name_exists(resource) {
    resource.expressions.instance_name.references[_]
}

# Combined rule to ensure all conditions are met
has_required_resources {
    has_lightsail_instance
    has_lightsail_static_ip
    has_lightsail_static_ip_attachment
}
Task: create Amazon Lightsail with dualstack IP

Specification:
have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument
    with "ip_address_type" = "dualstack"

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

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

resource "aws_lightsail_instance" "custom" {
  name              = "custom"
  availability_zone = "us-east-1b"
  blueprint_id      = "wordpress"
  bundle_id         = "nano_2_0"
  ip_address_type = "dualstack"
 }

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

default has_valid_lightsail_instance = false

# Main rule to check for a valid aws_lightsail_instance with specific arguments
has_valid_lightsail_instance {
    resource := input.planned_values.root_module.resources[_]
    resource.type == "aws_lightsail_instance"
    resource.values.name
    resource.values.availability_zone
    resource.values.blueprint_id
    resource.values.bundle_id
    resource.values.ip_address_type == "dualstack"
}
Task: create AWS Lightsail that creates a managed database

Specification:
have one "aws_lightsail_database" resource
    with relational_database_name argument
    with master_database_name 
    with master_password
    with master_username
    with blueprint_id
    with bundle_id
    

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

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

resource "aws_lightsail_database" "test" {
  relational_database_name = "test"
  availability_zone        = "us-east-1a"
  master_database_name     = "testdatabasename"
  master_password          = "testdatabasepassword"
  master_username          = "test"
  blueprint_id             = "mysql_8_0"
  bundle_id                = "micro_1_0"
}

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

default has_valid_lightsail_database = false

# Rule for aws_lightsail_database resource with specific arguments
has_valid_lightsail_database {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_database"
    resource.values.relational_database_name
    resource.values.master_database_name
    resource.values.master_password
    resource.values.master_username
    resource.values.blueprint_id
    resource.values.bundle_id
}
Task: create an AWS Lightsail instance that creates a mysql database

Specification:
have one "aws_lightsail_database" resource
    with relational_database_name argument
    with master_database_name 
    with master_password
    with master_username
    with blueprint_id = mysql_8_0
    with bundle_id
    

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

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

resource "aws_lightsail_database" "test" {
  relational_database_name = "test"
  availability_zone        = "us-east-1a"
  master_database_name     = "testdatabasename"
  master_password          = "testdatabasepassword"
  master_username          = "test"
  blueprint_id             = "mysql_8_0"
  bundle_id                = "micro_1_0"
}

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

default has_valid_lightsail_database = false

# Rule for aws_lightsail_database resource with specific arguments
has_valid_lightsail_database {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_database"
    resource.values.relational_database_name
    resource.values.master_database_name
    resource.values.master_password
    resource.values.master_username
    resource.values.blueprint_id == "mysql_8_0"
    resource.values.bundle_id
}
Task: create AWS Lightsail that creates a mysql database. It should allow daily backups to take place between 16:00 and 16:30 each day and  requires any maintiance tasks (anything that would cause an outage, including changing some attributes) to take place on Tuesdays between 17:00 and 17:30

Specification:
have one "aws_lightsail_database" resource
    with relational_database_name argument
    with master_database_name 
    with master_password
    with master_username
    with blueprint_id
    with bundle_id
    with  preferred_backup_window    = "16:00-16:30"
  preferred_maintenance_window = "Tue:17:00-Tue:17:30"

    

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

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

resource "aws_lightsail_database" "test" {
  relational_database_name     = "test"
  availability_zone            = "us-east-1a"
  master_database_name         = "testdatabasename"
  master_password              = "testdatabasepassword"
  master_username              = "test"
  blueprint_id                 = "mysql_8_0"
  bundle_id                    = "micro_1_0"
  preferred_backup_window      = "16:00-16:30"
  preferred_maintenance_window = "Tue:17:00-Tue:17:30"
}

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

default has_valid_lightsail_database = false

# Rule for aws_lightsail_database resource with specific arguments
has_valid_lightsail_database {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_database"
    resource.values.relational_database_name
    resource.values.master_database_name
    resource.values.master_password
    resource.values.master_username
    resource.values.bundle_id
    resource.values.preferred_backup_window == "16:00-16:30"
    resource.values.preferred_maintenance_window == "Tue:17:00-Tue:17:30"
    
}
Task: AWS Lightsail that creates a postgres database, which enable creating a final snapshot of your database on deletion

Specification:
"have one ""aws_lightsail_database"" resource
    with relational_database_name argument
    with master_database_name 
    with master_password
    with master_username
    with blueprint_id = postgres_12
    with bundle_id
    with final_snapshot_name

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

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

resource "aws_lightsail_database" "test" {
  relational_database_name     = "test"
  availability_zone            = "us-east-1a"
  master_database_name         = "testdatabasename"
  master_password              = "testdatabasepassword"
  master_username              = "test"
  blueprint_id                 = "postgres_12"
  bundle_id                    = "micro_1_0"
  final_snapshot_name          = "MyFinalSnapshot"
}

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

default has_valid_lightsail_database = false

# Rule for aws_lightsail_database resource with specific arguments
has_valid_lightsail_database {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_database"
    resource.values.relational_database_name
    resource.values.master_database_name
    resource.values.master_password
    resource.values.master_username
    resource.values.blueprint_id == "postgres_12"
    resource.values.bundle_id
    resource.values.final_snapshot_name
}
Task: AWS Lightsail that creates a postgres database, which enable applying changes immediately instead of waiting for a maintiance window

Specification:
"have one ""aws_lightsail_database"" resource
    with relational_database_name argument
    with master_database_name 
    with master_password
    with master_username
    with blueprint_id = postgres_12
    with bundle_id
    apply_immediately  = true

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

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

resource "aws_lightsail_database" "test" {
  relational_database_name = "test"
  availability_zone        = "us-east-1a"
  master_database_name     = "testdatabasename"
  master_password          = "testdatabasepassword"
  master_username          = "test"
  blueprint_id             = "postgres_12"
  bundle_id                = "micro_1_0"
  apply_immediately        = true
}

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

default has_valid_lightsail_database = false

# Rule for aws_lightsail_database resource with specific arguments
has_valid_lightsail_database {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_database"
    resource.values.relational_database_name
    resource.values.master_database_name
    resource.values.master_password
    resource.values.master_username
    resource.values.blueprint_id == "postgres_12"
    resource.values.bundle_id
    resource.values.apply_immediately == true
}
Task: create a Lightsail Disk resource

Specification:
have one aws_lightsail_disk resource
    with name
    with size_in_gb
    with availability_zone

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

data "aws_availability_zones" "available" {
  state = "available"

  filter {
    name   = "opt-in-status"
    values = ["opt-in-not-required"]
  }
}

resource "aws_lightsail_disk" "test" {
  name              = "test"
  size_in_gb        = 8
  availability_zone = data.aws_availability_zones.available.names[0]
}

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

default has_valid_lightsail_disk = false

# Rule for aws_lightsail_disk resource with specific arguments
has_valid_lightsail_disk {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_disk"
    resource.values.name
    resource.values.size_in_gb
    resource.values.availability_zone
}
Task: Create a Lightsail Disk resource and attaches the Lightsail disk to a Lightsail Instance

Specification:
have one aws_lightsail_disk resource
    with name
    with size_in_gb
    with availability_zone

have one aws_lightsail_disk_attachment
    with disk_name
    with instance_name
    with disk_path

have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument

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

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

data "aws_availability_zones" "available" {
  state = "available"

  filter {
    name   = "opt-in-status"
    values = ["opt-in-not-required"]
  }
}

resource "aws_lightsail_disk" "test" {
  name              = "test-disk"
  size_in_gb        = 8
  availability_zone = data.aws_availability_zones.available.names[0]
}

resource "aws_lightsail_instance" "test" {
  name              = "test-instance"
  availability_zone = data.aws_availability_zones.available.names[0]
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_1_0"
}

resource "aws_lightsail_disk_attachment" "test" {
  disk_name     = aws_lightsail_disk.test.name
  instance_name = aws_lightsail_instance.test.name
  disk_path     = "/dev/xvdf"
}

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

default has_valid_lightsail_disk = false

# Rule for aws_lightsail_disk resource with specific arguments
has_valid_lightsail_disk {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_disk"
    resource.values.name
    resource.values.size_in_gb
    resource.values.availability_zone
}
Task: Set up a storage unit in Lightsail and link it with a Lightsail compute service.

Specification:
have one aws_lightsail_disk resource
    with name
    with size_in_gb
    with availability_zone

have one aws_lightsail_disk_attachment
    with disk_name
    with instance_name
    with disk_path

have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument

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

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

data "aws_availability_zones" "available" {
  state = "available"

  filter {
    name   = "opt-in-status"
    values = ["opt-in-not-required"]
  }
}

resource "aws_lightsail_disk" "test" {
  name              = "test-disk"
  size_in_gb        = 8
  availability_zone = data.aws_availability_zones.available.names[0]
}

resource "aws_lightsail_instance" "test" {
  name              = "test-instance"
  availability_zone = data.aws_availability_zones.available.names[0]
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_1_0"
}

resource "aws_lightsail_disk_attachment" "test" {
  disk_name     = aws_lightsail_disk.test.name
  instance_name = aws_lightsail_instance.test.name
  disk_path     = "/dev/xvdf"
}

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

default has_valid_lightsail_disk = false

# Rule for aws_lightsail_disk resource with specific arguments
has_valid_lightsail_disk {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_disk"
    resource.values.name
    resource.values.size_in_gb
    resource.values.availability_zone
}
Task: Create a Lightsail instance with multiple attached disks

Specification:
have multiple aws_lightsail_disk resource
    with name
    with size_in_gb
    with availability_zone

have multiple aws_lightsail_disk_attachment
    with disk_name
    with instance_name
    with disk_path

have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument

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_availability_zones" "available" {
  state = "available"

  filter {
    name   = "opt-in-status"
    values = ["opt-in-not-required"]
  }
}

resource "aws_lightsail_disk" "test1" {
  name              = "test-disk-1"
  size_in_gb        = 8
  availability_zone = data.aws_availability_zones.available.names[0]
}

resource "aws_lightsail_disk" "test2" {
  name              = "test-disk-2"
  size_in_gb        = 8
  availability_zone = data.aws_availability_zones.available.names[0]
}

resource "aws_lightsail_instance" "test" {
  name              = "test-instance"
  availability_zone = data.aws_availability_zones.available.names[0]
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_1_0"
}

resource "aws_lightsail_disk_attachment" "test1" {
  disk_name     = aws_lightsail_disk.test1.name
  instance_name = aws_lightsail_instance.test.name
  disk_path     = "/dev/xvdf"
}

resource "aws_lightsail_disk_attachment" "test2" {
  disk_name     = aws_lightsail_disk.test2.name
  instance_name = aws_lightsail_instance.test.name
  disk_path     = "/dev/xvdg"
}

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

default has_valid_resources = false

# Rule for multiple aws_lightsail_disk resources
has_valid_lightsail_disks {
    count([disk | disk := input.planned_values.root_module.resources[_]; disk.type == "aws_lightsail_disk"; disk.values.name; disk.values.size_in_gb; disk.values.availability_zone]) > 0
}

# Rule for multiple aws_lightsail_disk_attachment resources
has_valid_lightsail_disk_attachments {
    count([attachment | attachment := input.planned_values.root_module.resources[_]; attachment.type == "aws_lightsail_disk_attachment"; attachment.values.disk_name; attachment.values.instance_name; attachment.values.disk_path]) > 0
}

# Rule for aws_lightsail_instance resource with specific arguments
has_valid_lightsail_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_instance"
    resource.values.name
    resource.values.availability_zone
    resource.values.blueprint_id
    resource.values.bundle_id
}

# Combined rule to ensure all conditions are met
has_valid_resources {
    has_valid_lightsail_disks
    has_valid_lightsail_disk_attachments
    has_valid_lightsail_instance
}
Task: Create a lightsail resource access to a bucket.

Specification:
have one aws_lightsail_bucket
    with name
    with bundle_id

have one aws_lightsail_bucket_resource_access
    with bucket_name
    with resource_name

have one "aws_lightsail_instance" resource
    with "name" argument
    with "availability_zone" argument
    with "blueprint_id" argument
    with "bundle_id" argument

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

resource "aws_lightsail_bucket" "test" {
  name      = "mytestbucket"
  bundle_id = "small_1_0"
}

resource "aws_lightsail_instance" "test" {
  name              = "mytestinstance"
  availability_zone = "us-east-1b"
  blueprint_id      = "amazon_linux_2"
  bundle_id         = "nano_1_0"
}

resource "aws_lightsail_bucket_resource_access" "test" {
  bucket_name   = aws_lightsail_bucket.test.name
  resource_name = aws_lightsail_instance.test.name
}

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

default has_valid_resources = false

# Rule for aws_lightsail_bucket resource
has_valid_lightsail_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_bucket"
    resource.values.name
    resource.values.bundle_id
}

# Rule for aws_lightsail_bucket_resource_access resource
has_valid_lightsail_bucket_access {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_bucket_resource_access"
    resource.values.bucket_name
    resource.values.resource_name
}

# Rule for aws_lightsail_instance resource with specific arguments
has_valid_lightsail_instance {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_instance"
    resource.values.name
    resource.values.availability_zone
    resource.values.blueprint_id
    resource.values.bundle_id
}

# Combined rule to ensure all conditions are met
has_valid_resources {
    has_valid_lightsail_bucket
    has_valid_lightsail_bucket_access
    has_valid_lightsail_instance
}
Task: Provides a lightsail certificate.

Specification:
have one aws_lightsail_certificate
    with name
    with domain_name

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

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

resource "aws_lightsail_certificate" "test" {
  name                      = "test"
  domain_name               = "testdomain.com"
  subject_alternative_names = ["www.testdomain.com"]
}

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

default has_valid_lightsail_certificate = false

# Rule for aws_lightsail_certificate resource with specific arguments
has_valid_lightsail_certificate {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_certificate"
    resource.values.name
    resource.values.domain_name
}
Task: managing an AWS Lightsail Distribution with bucket as the origin

Specification:
have one aws_lightsail_distribution
    with name
    with bundle_id
    with default_cache_behavior 
        with behavior
    with origin 
        with name
        with region_name
    with cache_behavior_settings 
        with forwarded_cookies
            with cookies_allow_list 
        with forwarded_headers  
            with headers_allow_list 
        with forwarded_query_strings 
            with query_strings_allowed_list

have one aws_lightsail_bucket
    with name
    with bundle_id

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

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

resource "aws_lightsail_bucket" "test" {
  name      = "test-bucket"
  bundle_id = "small_1_0"
}
resource "aws_lightsail_distribution" "test" {
  name      = "test-distribution"
  bundle_id = "small_1_0"
  origin {
    name        = aws_lightsail_bucket.test.name
    region_name = aws_lightsail_bucket.test.region
  }
  default_cache_behavior {
    behavior = "cache"
  }
  cache_behavior_settings {
    allowed_http_methods = "GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE"
    cached_http_methods  = "GET,HEAD"
    default_ttl          = 86400
    maximum_ttl          = 31536000
    minimum_ttl          = 0
    forwarded_cookies {
      option = "none"
    }
    forwarded_headers {
      option = "default"
    }
    forwarded_query_strings {
      option = false
    }
  }
}

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

default has_valid_resources = false

# Rule for aws_lightsail_distribution resource
has_valid_lightsail_distribution {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_distribution"
    resource.values.name
    resource.values.bundle_id
}

# Rule for aws_lightsail_bucket resource
has_valid_lightsail_bucket {
    some i
    resource := input.planned_values.root_module.resources[i]
    resource.type == "aws_lightsail_bucket"
    resource.values.name
    resource.values.bundle_id
}

# Combined rule to ensure both conditions are met
has_valid_resources {
    has_valid_lightsail_distribution
    has_valid_lightsail_bucket
}