This template creates an AWS VPC Lattice Service with a custom domain and an associated authorization policy using AWS IAM.

Terraform Template

resource "aws_vpclattice_auth_policy" "example" {
  policy = jsonencode({
 Version = "2012-10-17"
 Statement = [
 {
 Action = "*"
 Effect = "Allow"
 Principal = "*"
 Resource = "*"
 Condition = {
 StringNotEqualsIgnoreCase = {
 "aws:PrincipalType" = "anonymous"
 }
 }
 }
 ]
 })
  resource_identifier = aws_vpclattice_service.example.arn
}

resource "aws_vpclattice_service" "example" {
  auth_type = "AWS_IAM"
  custom_domain_name = "example.com"
  name = "example-vpclattice-service"
}