Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

test(terraform): expand Floci IaC compatibility coverage (#1834)

kotov2288765cde6ddef
diff --git a/README.md b/README.md
index 8a450caf65..4fea80c1d2 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,8 @@ Lambda, RDS, Neptune, ElastiCache, MSK, ECS, EC2, EKS, OpenSearch, CodeBuild, an
Point standard AWS clients at `http://localhost:4566`. Existing credentials, regions, SDKs, CLI commands, and IaC workflows stay familiar.
+Terraform can provision AWS-shaped resources locally through Floci using the standard HashiCorp AWS provider. See the [Terraform with Floci guide](docs/getting-started/terraform.md) for provider configuration, resource examples, and optional emulated S3 state.
+
</details>
<details>
@@ -695,11 +697,11 @@ The [`compatibility-tests`](./compatibility-tests/) directory validates Floci ac
| `sdk-test-python` | Python 3 | boto3 | 311 |
| `sdk-test-go` | Go | AWS SDK for Go v2 + RDS Data API SDK v1 | 157 |
| `sdk-test-awscli` | Bash | AWS CLI v2 | 205 |
-| `compat-terraform` | Terraform | v1.10+ | 22 |
-| `compat-opentofu` | OpenTofu | v1.9+ | 16 |
+| `compat-terraform` | Terraform | v1.10+ | 67 |
+| `compat-opentofu` | OpenTofu | v1.9+ | 41 |
| `compat-cdk` | AWS CDK | v2+ | 20 |
-**2,506 automated compatibility tests across 5 SDKs and 3 IaC tools.**
+**2,576 automated compatibility tests across 5 SDKs and 3 IaC tools.**
## Migrating from LocalStack
diff --git a/compatibility-tests/README.md b/compatibility-tests/README.md
index d18c5099c6..7c40544155 100644
--- a/compatibility-tests/README.md
+++ b/compatibility-tests/README.md
@@ -44,6 +44,8 @@ just test-awscli
| [`compat-opentofu`](compat-opentofu/) | OpenTofu | `./run.sh` |
| [`compat-terraform`](compat-terraform/) | Terraform | `./run.sh` |
+The Terraform suite uses the standard `hashicorp/aws` provider against Floci's local endpoint. It validates `init`, `validate`, `plan`, `apply`, resource reads, and `destroy` without creating resources in a real AWS account. See the [Terraform with Floci guide](../docs/getting-started/terraform.md) for a copy-paste setup.
+
## Prerequisites
- **Floci running** on `http://localhost:4566` (or set `FLOCI_ENDPOINT`)
@@ -93,6 +95,21 @@ just test-typescript
just test-awscli
```
+### IaC tools
+
+The Terraform, OpenTofu, and CDK suites aren't part of `just test-all` — run them individually by name:
+
+```bash
+# Terraform
+compat-terraform/run.sh
+
+# OpenTofu
+compat-opentofu/run.sh
+
+# AWS CDK
+compat-cdk/run.sh
+```
+
Bats-based suites keep their normal console output and also write JUnit XML reports:
- `sdk-test-awscli/test-results/junit.xml`
diff --git a/compatibility-tests/compat-opentofu/main.tf b/compatibility-tests/compat-opentofu/main.tf
index 8854f38c7f..8b2fdc24d3 100644
--- a/compatibility-tests/compat-opentofu/main.tf
+++ b/compatibility-tests/compat-opentofu/main.tf
@@ -2,7 +2,8 @@
# ── S3 Bucket ──────────────────────────────────────────────────────────────
resource "aws_s3_bucket" "app" {
- bucket = "floci-compat-app"
+ bucket = "floci-compat-app"
+ force_destroy = true
}
resource "aws_s3_bucket_versioning" "app" {
@@ -83,6 +84,222 @@ resource "aws_iam_role" "lambda_exec" {
})
}
+# ── ECR Repository ─────────────────────────────────────────────────────────
+resource "aws_ecr_repository" "app" {
+ name = "floci-compat-app"
+ image_tag_mutability = "MUTABLE"
+
+ image_scanning_configuration {
+ scan_on_push = false
+ }
+}
+
+# ── ECS Cluster ─────────────────────────────────────────────────────────────
+resource "aws_ecs_cluster" "app" {
+ name = "floci-compat-cluster"
+}
+
+# ── KMS Key ─────────────────────────────────────────────────────────────────
+resource "aws_kms_key" "compat" {
+ description = "Floci OpenTofu compatibility key"
+ deletion_window_in_days = 7
+ enable_key_rotation = false
+}
+
+# ── Kinesis Stream ──────────────────────────────────────────────────────────
+resource "aws_kinesis_stream" "events" {
+ name = "floci-compat-events"
+ shard_count = 1
+ retention_period = 24
+}
+
+# ── CloudWatch Log Group ────────────────────────────────────────────────────
+resource "aws_cloudwatch_log_group" "app" {
+ name = "/floci/compat/app"
+ retention_in_days = 1
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+# ── EventBridge Event Bus ───────────────────────────────────────────────────
+resource "aws_cloudwatch_event_bus" "compat" {
+ name = "floci-compat-bus"
+}
+
+# ── Step Functions State Machine ────────────────────────────────────────────
+resource "aws_sfn_state_machine" "compat" {
+ name = "floci-compat-state-machine"
+ role_arn = aws_iam_role.lambda_exec.arn
+ definition = jsonencode({
+ Comment = "Floci OpenTofu compatibility state machine"
+ StartAt = "Pass"
+ States = {
+ Pass = {
+ Type = "Pass"
+ End = true
+ }
+ }
+ })
+}
+
+# ── CloudFormation Stack ────────────────────────────────────────────────────
+resource "aws_cloudformation_stack" "compat" {
+ name = "floci-compat-stack"
+ template_body = jsonencode({
+ Resources = {
+ CompatBucket = {
+ Type = "AWS::S3::Bucket"
+ Properties = {
+ BucketName = "floci-compat-cfn-bucket"
+ }
+ }
+ }
+ })
+}
+
+# ── EKS Cluster ─────────────────────────────────────────────────────────────
+resource "aws_eks_cluster" "compat" {
+ name = "floci-compat-eks"
+ role_arn = aws_iam_role.lambda_exec.arn
+
+ vpc_config {
+ subnet_ids = [aws_subnet.compat.id]
+ }
+}
+
+# ── API Gateway v2 ──────────────────────────────────────────────────────────
+resource "aws_apigatewayv2_api" "compat" {
+ name = "floci-compat-http-api"
+ protocol_type = "HTTP"
+}
+
+# ── AppConfig Application ───────────────────────────────────────────────────
+resource "aws_appconfig_application" "compat" {
+ name = "floci-compat-appconfig"
+ description = "Floci OpenTofu compatibility application"
+}
+
+# ── AWS Backup Vault ─────────────────────────────────────────────────────────
+resource "aws_backup_vault" "compat" {
+ name = "floci-compat-vault"
+}
+
+# ── Cloud Map Namespace ─────────────────────────────────────────────────────
+resource "aws_service_discovery_private_dns_namespace" "compat" {
+ name = "floci-compat.internal"
+ description = "Floci OpenTofu compatibility namespace"
+ vpc = aws_vpc.compat.id
+}
+
+# ── CodeDeploy Application ──────────────────────────────────────────────────
+resource "aws_codedeploy_app" "compat" {
+ name = "floci-compat-codedeploy"
+ compute_platform = "Server"
+}
+
+# ── ACM Certificate ─────────────────────────────────────────────────────────
+resource "aws_acm_certificate" "compat" {
+ domain_name = "floci-compat.internal"
+ validation_method = "DNS"
+}
+
+# ── SES Email Identity ──────────────────────────────────────────────────────
+resource "aws_ses_email_identity" "compat" {
+ email = "[email protected]"
+}
+
+# ── EventBridge Scheduler ───────────────────────────────────────────────────
+resource "aws_scheduler_schedule" "compat" {
+ name = "floci-compat-schedule"
+ schedule_expression = "rate(1 hour)"
+ schedule_expression_timezone = "UTC"
+
+ flexible_time_window {
+ mode = "OFF"
+ }
+
+ target {
+ arn = aws_sqs_queue.jobs.arn
+ role_arn = aws_iam_role.lambda_exec.arn
+ }
+}
+
+# ── WAFv2 Web ACL ───────────────────────────────────────────────────────────
+resource "aws_wafv2_web_acl" "compat" {
+ name = "floci-compat-waf"
+ scope = "REGIONAL"
+
+ default_action {
+ allow {}
+ }
+
+ visibility_config {
+ cloudwatch_metrics_enabled = false
+ metric_name = "flociCompatWaf"
+ sampled_requests_enabled = false
+ }
+}
+
+# ── Cost and Usage Report ───────────────────────────────────────────────────
+resource "aws_cur_report_definition" "compat" {
+ report_name = "floci-compat-report"
+ time_unit = "HOURLY"
+ format = "Parquet"
+ compression = "Parquet"
+ additional_schema_elements = ["RESOURCES"]
+ s3_bucket = aws_s3_bucket.app.bucket
+ s3_prefix = "cur"
+ s3_region = "us-east-1"
+}
+
+# ── AppSync GraphQL API ─────────────────────────────────────────────────────
+resource "aws_appsync_graphql_api" "compat" {
+ name = "floci-compat-graphql"
+ authentication_type = "API_KEY"
+ schema = "type Query { health: String }"
+}
+
+# ── ElastiCache Replication Group ───────────────────────────────────────────
+resource "aws_elasticache_replication_group" "compat" {
+ replication_group_id = "floci-compat-cache"
+ description = "Floci OpenTofu compatibility cache"
+ engine = "redis"
+ node_type = "cache.t3.micro"
+ num_cache_clusters = 1
+ port = 6379
+}
+
+# ── Firehose Delivery Stream ────────────────────────────────────────────────
+resource "aws_kinesis_firehose_delivery_stream" "compat" {
+ name = "floci-compat-firehose-basic"
+ destination = "extended_s3"
+
+ extended_s3_configuration {
+ role_arn = aws_iam_role.lambda_exec.arn
+ bucket_arn = aws_s3_bucket.app.arn
+ buffering_size = 5
+ buffering_interval = 60
+ compression_format = "UNCOMPRESSED"
+ }
+}
+
+# ── EventBridge Pipe ────────────────────────────────────────────────────────
+resource "aws_pipes_pipe" "compat" {
+ name = "floci-compat-pipe"
+ role_arn = aws_iam_role.lambda_exec.arn
+ source = aws_sqs_queue.jobs.arn
+ target = aws_sns_topic.events.arn
+
+ source_parameters {
+ sqs_queue_parameters {
+ batch_size = 1
+ maximum_batching_window_in_seconds = 0
+ }
+ }
+}
+
# ── SSM Parameters ─────────────────────────────────────────────────────────
resource "aws_ssm_parameter" "db_url" {
name = "/floci-compat/db-url"
diff --git a/compatibility-tests/compat-opentofu/provider.tf b/compatibility-tests/compat-opentofu/provider.tf
index 2c269ad9c0..ae4f512135 100644
--- a/compatibility-tests/compat-opentofu/provider.tf
+++ b/compatibility-tests/compat-opentofu/provider.tf
@@ -25,18 +25,49 @@ provider "aws" {
s3_use_path_style = true
endpoints {
- s3 = var.endpoint
- sqs = var.endpoint
- sns = var.endpoint
- dynamodb = var.endpoint
- lambda = var.endpoint
- iam = var.endpoint
- sts = var.endpoint
- ssm = var.endpoint
- secretsmanager = var.endpoint
- ec2 = var.endpoint
- route53 = var.endpoint
- ses = var.endpoint
- guardduty = var.endpoint
+ s3 = var.endpoint
+ sqs = var.endpoint
+ sns = var.endpoint
+ dynamodb = var.endpoint
+ lambda = var.endpoint
+ iam = var.endpoint
+ sts = var.endpoint
+ ssm = var.endpoint
+ secretsmanager = var.endpoint
+ ec2 = var.endpoint
+ route53 = var.endpoint
+ guardduty = var.endpoint
+ elasticache = var.endpoint
+ ecr = var.endpoint
+ ecs = var.endpoint
+ kms = var.endpoint
+ kinesis = var.endpoint
+ logs = var.endpoint
+ events = var.endpoint
+ sfn = var.endpoint
+ cloudformation = var.endpoint
+ eks = var.endpoint
+ codebuild = var.endpoint
+ apigateway = var.endpoint
+ apigatewayv2 = var.endpoint
+ appconfig = var.endpoint
+ appsync = var.endpoint
+ athena = var.endpoint
+ backup = var.endpoint
+ servicediscovery = var.endpoint
+ codedeploy = var.endpoint
+ acm = var.endpoint
+ ses = var.endpoint
+ scheduler = var.endpoint
+ transfer = var.endpoint
+ wafv2 = var.endpoint
+ cloudtrail = var.endpoint
+ cur = var.endpoint
+ glue = var.endpoint
+ firehose = var.endpoint
+ pipes = var.endpoint
+ batch = var.endpoint
+ neptune = var.endpoint
+ opensearch = var.endpoint
}
}
diff --git a/compatibility-tests/compat-opentofu/test/opentofu.bats b/compatibility-tests/compat-opentofu/test/opentofu.bats
index 1ecdc2e9ba..cddd4c9f71 100644
--- a/compatibility-tests/compat-opentofu/test/opentofu.bats
+++ b/compatibility-tests/compat-opentofu/test/opentofu.bats
@@ -106,6 +106,147 @@ setup() {
assert_output --partial "floci-compat"
}
+@test "OpenTofu: ECR repository created" {
+ run aws_cmd ecr describe-repositories --repository-names floci-compat-app
+ assert_success
+ assert_output --partial "floci-compat-app"
+}
+
+@test "OpenTofu: ECS cluster created" {
+ run aws_cmd ecs describe-clusters --clusters floci-compat-cluster
+ assert_success
+ assert_output --partial "floci-compat-cluster"
+ assert_output --partial "ACTIVE"
+}
+
+@test "OpenTofu: KMS key created" {
+ run aws_cmd kms list-keys
+ assert_success
+ [ "$(aws_cmd kms list-keys --query 'length(Keys)' --output text)" -gt 0 ]
+}
+
+@test "OpenTofu: Kinesis stream created" {
+ run aws_cmd kinesis describe-stream-summary --stream-name floci-compat-events
+ assert_success
+ assert_output --partial "ACTIVE"
+}
+
+@test "OpenTofu: CloudWatch log group created" {
+ run aws_cmd logs describe-log-groups --log-group-name-prefix /floci/compat/app
+ assert_success
+ assert_output --partial "/floci/compat/app"
+}
+
+@test "OpenTofu: EventBridge event bus created" {
+ run aws_cmd events describe-event-bus --name floci-compat-bus
+ assert_success
+ assert_output --partial "floci-compat-bus"
+}
+
+@test "OpenTofu: Step Functions state machine created" {
+ run aws_cmd stepfunctions list-state-machines
+ assert_success
+ assert_output --partial "floci-compat-state-machine"
+}
+
+@test "OpenTofu: CloudFormation stack created" {
+ run aws_cmd cloudformation describe-stacks --stack-name floci-compat-stack
+ assert_success
+ assert_output --partial "floci-compat-stack"
+}
+
+@test "OpenTofu: EKS cluster created" {
+ run aws_cmd eks describe-cluster --name floci-compat-eks
+ assert_success
+ assert_output --partial "floci-compat-eks"
+ assert_output --partial "ACTIVE"
+}
+
+@test "OpenTofu: API Gateway v2 HTTP API created" {
+ run aws_cmd apigatewayv2 get-apis
+ assert_success
+ assert_output --partial "floci-compat-http-api"
+}
+
+@test "OpenTofu: AppConfig application created" {
+ run aws_cmd appconfig list-applications
+ assert_success
+ assert_output --partial "floci-compat-appconfig"
+}
+
+@test "OpenTofu: Backup vault created" {
+ run aws_cmd backup describe-backup-vault --backup-vault-name floci-compat-vault
+ assert_success
+ assert_output --partial "floci-compat-vault"
+}
+
+@test "OpenTofu: Cloud Map namespace created" {
+ run aws_cmd servicediscovery list-namespaces
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "OpenTofu: CodeDeploy application created" {
+ run aws_cmd deploy get-application --application-name floci-compat-codedeploy
+ assert_success
+ assert_output --partial "floci-compat-codedeploy"
+}
+
+@test "OpenTofu: ACM certificate created" {
+ run aws_cmd acm list-certificates
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "OpenTofu: SES identity created" {
+ run aws_cmd ses get-identity-verification-attributes \
+ --identities [email protected]
+ assert_success
+ assert_output --partial "[email protected]"
+}
+
+@test "OpenTofu: EventBridge schedule created" {
+ run aws_cmd scheduler get-schedule --name floci-compat-schedule
+ assert_success
+ assert_output --partial "floci-compat-schedule"
+}
+
+@test "OpenTofu: WAFv2 web ACL created" {
+ run aws_cmd wafv2 list-web-acls --scope REGIONAL
+ assert_success
+ assert_output --partial "floci-compat-waf"
+}
+
+@test "OpenTofu: Cost and Usage Report created" {
+ run aws_cmd cur describe-report-definitions
+ assert_success
+ assert_output --partial "floci-compat-report"
+}
+
+@test "OpenTofu: AppSync GraphQL API created" {
+ run aws_cmd appsync list-graphql-apis
+ assert_success
+ assert_output --partial "floci-compat-graphql"
+}
+
+@test "OpenTofu: ElastiCache replication group created" {
+ run aws_cmd elasticache describe-replication-groups --replication-group-id floci-compat-cache
+ assert_success
+ assert_output --partial "floci-compat-cache"
+}
+
+@test "OpenTofu: Firehose delivery stream created" {
+ run aws_cmd firehose list-delivery-streams
+ assert_success
+ assert_output --partial "floci-compat-firehose-basic"
+}
+
+@test "OpenTofu: EventBridge pipe created" {
+ run aws_cmd pipes list-pipes
+ assert_success
+ assert_output --partial "floci-compat-pipe"
+}
+
@test "OpenTofu: VPC created with custom DNS settings" {
run aws_cmd ec2 describe-vpcs \
--filters "Name=tag:Name,Values=floci-compat-vpc"
diff --git a/compatibility-tests/compat-terraform/backend.hcl b/compatibility-tests/compat-terraform/backend.hcl
index d9d87c4291..26779e0455 100644
--- a/compatibility-tests/compat-terraform/backend.hcl
+++ b/compatibility-tests/compat-terraform/backend.hcl
@@ -7,7 +7,7 @@ access_key = "test"
secret_key = "test"
skip_credentials_validation = true
skip_region_validation = true
-force_path_style = true
+use_path_style = true
dynamodb_endpoint = "http://localhost:4566"
dynamodb_table = "tflock"
diff --git a/compatibility-tests/compat-terraform/main.tf b/compatibility-tests/compat-terraform/main.tf
index 6ef11a7c57..be975a880e 100644
--- a/compatibility-tests/compat-terraform/main.tf
+++ b/compatibility-tests/compat-terraform/main.tf
@@ -2,7 +2,8 @@
# -- S3 Bucket ------------------------------------------------------------------
resource "aws_s3_bucket" "app" {
- bucket = "floci-compat-app"
+ bucket = "floci-compat-app"
+ force_destroy = true
}
resource "aws_s3_bucket_versioning" "app" {
@@ -87,6 +88,222 @@ resource "aws_iam_role" "lambda_exec" {
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json
}
+# -- ECR Repository ------------------------------------------------------------
+resource "aws_ecr_repository" "app" {
+ name = "floci-compat-app"
+ image_tag_mutability = "MUTABLE"
+
+ image_scanning_configuration {
+ scan_on_push = false
+ }
+}
+
+# -- ECS Cluster ---------------------------------------------------------------
+resource "aws_ecs_cluster" "app" {
+ name = "floci-compat-cluster"
+}
+
+# -- KMS Key -------------------------------------------------------------------
+resource "aws_kms_key" "compat" {
+ description = "Floci Terraform compatibility key"
+ deletion_window_in_days = 7
+ enable_key_rotation = false
+}
+
+# -- Kinesis Stream ------------------------------------------------------------
+resource "aws_kinesis_stream" "events" {
+ name = "floci-compat-events"
+ shard_count = 1
+ retention_period = 24
+}
+
+# -- CloudWatch Log Group ------------------------------------------------------
+resource "aws_cloudwatch_log_group" "app" {
+ name = "/floci/compat/app"
+ retention_in_days = 1
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+# -- EventBridge Event Bus -----------------------------------------------------
+resource "aws_cloudwatch_event_bus" "compat" {
+ name = "floci-compat-bus"
+}
+
+# -- Step Functions State Machine ----------------------------------------------
+resource "aws_sfn_state_machine" "compat" {
+ name = "floci-compat-state-machine"
+ role_arn = aws_iam_role.lambda_exec.arn
+ definition = jsonencode({
+ Comment = "Floci Terraform compatibility state machine"
+ StartAt = "Pass"
+ States = {
+ Pass = {
+ Type = "Pass"
+ End = true
+ }
+ }
+ })
+}
+
+# -- CloudFormation Stack ------------------------------------------------------
+resource "aws_cloudformation_stack" "compat" {
+ name = "floci-compat-stack"
+ template_body = jsonencode({
+ Resources = {
+ CompatBucket = {
+ Type = "AWS::S3::Bucket"
+ Properties = {
+ BucketName = "floci-compat-cfn-bucket"
+ }
+ }
+ }
+ })
+}
+
+# -- EKS Cluster ---------------------------------------------------------------
+resource "aws_eks_cluster" "compat" {
+ name = "floci-compat-eks"
+ role_arn = aws_iam_role.lambda_exec.arn
+
+ vpc_config {
+ subnet_ids = [aws_subnet.compat.id]
+ }
+}
+
+# -- API Gateway v2 ------------------------------------------------------------
+resource "aws_apigatewayv2_api" "compat" {
+ name = "floci-compat-http-api"
+ protocol_type = "HTTP"
+}
+
+# -- AppConfig Application -----------------------------------------------------
+resource "aws_appconfig_application" "compat" {
+ name = "floci-compat-appconfig"
+ description = "Floci Terraform compatibility application"
+}
+
+# -- AWS Backup Vault ----------------------------------------------------------
+resource "aws_backup_vault" "compat" {
+ name = "floci-compat-vault"
+}
+
+# -- Cloud Map Namespace -------------------------------------------------------
+resource "aws_service_discovery_private_dns_namespace" "compat" {
+ name = "floci-compat.internal"
+ description = "Floci Terraform compatibility namespace"
+ vpc = aws_vpc.compat.id
+}
+
+# -- CodeDeploy Application ----------------------------------------------------
+resource "aws_codedeploy_app" "compat" {
+ name = "floci-compat-codedeploy"
+ compute_platform = "Server"
+}
+
+# -- ACM Certificate -----------------------------------------------------------
+resource "aws_acm_certificate" "compat" {
+ domain_name = "floci-compat.internal"
+ validation_method = "DNS"
+}
+
+# -- SES Email Identity --------------------------------------------------------
+resource "aws_ses_email_identity" "compat" {
+ email = "[email protected]"
+}
+
+# -- EventBridge Scheduler -----------------------------------------------------
+resource "aws_scheduler_schedule" "compat" {
+ name = "floci-compat-schedule"
+ schedule_expression = "rate(1 hour)"
+ schedule_expression_timezone = "UTC"
+
+ flexible_time_window {
+ mode = "OFF"
+ }
+
+ target {
+ arn = aws_sqs_queue.jobs.arn
+ role_arn = aws_iam_role.lambda_exec.arn
+ }
+}
+
+# -- WAFv2 Web ACL -------------------------------------------------------------
+resource "aws_wafv2_web_acl" "compat" {
+ name = "floci-compat-waf"
+ scope = "REGIONAL"
+
+ default_action {
+ allow {}
+ }
+
+ visibility_config {
+ cloudwatch_metrics_enabled = false
+ metric_name = "flociCompatWaf"
+ sampled_requests_enabled = false
+ }
+}
+
+# -- Cost and Usage Report -----------------------------------------------------
+resource "aws_cur_report_definition" "compat" {
+ report_name = "floci-compat-report"
+ time_unit = "HOURLY"
+ format = "Parquet"
+ compression = "Parquet"
+ additional_schema_elements = ["RESOURCES"]
+ s3_bucket = aws_s3_bucket.app.bucket
+ s3_prefix = "cur"
+ s3_region = "us-east-1"
+}
+
+# -- AppSync GraphQL API -------------------------------------------------------
+resource "aws_appsync_graphql_api" "compat" {
+ name = "floci-compat-graphql"
+ authentication_type = "API_KEY"
+ schema = "type Query { health: String }"
+}
+
+# -- ElastiCache Replication Group ----------------------------------------------
+resource "aws_elasticache_replication_group" "compat" {
+ replication_group_id = "floci-compat-cache"
+ description = "Floci Terraform compatibility cache"
+ engine = "redis"
+ node_type = "cache.t3.micro"
+ num_cache_clusters = 1
+ port = 6379
+}
+
+# -- Firehose Delivery Stream --------------------------------------------------
+resource "aws_kinesis_firehose_delivery_stream" "compat" {
+ name = "floci-compat-firehose-basic"
+ destination = "extended_s3"
+
+ extended_s3_configuration {
+ role_arn = aws_iam_role.lambda_exec.arn
+ bucket_arn = aws_s3_bucket.app.arn
+ buffering_size = 5
+ buffering_interval = 60
+ compression_format = "UNCOMPRESSED"
+ }
+}
+
+# -- EventBridge Pipe ----------------------------------------------------------
+resource "aws_pipes_pipe" "compat" {
+ name = "floci-compat-pipe"
+ role_arn = aws_iam_role.lambda_exec.arn
+ source = aws_sqs_queue.jobs.arn
+ target = aws_sns_topic.events.arn
+
+ source_parameters {
+ sqs_queue_parameters {
+ batch_size = 1
+ maximum_batching_window_in_seconds = 0
+ }
+ }
+}
+
# -- SSM Parameters ------------------------------------------------------------
resource "aws_ssm_parameter" "db_url" {
name = "/floci-compat/db-url"
diff --git a/compatibility-tests/compat-terraform/provider.tf b/compatibility-tests/compat-terraform/provider.tf
index 2001fad068..c16782a62a 100644
--- a/compatibility-tests/compat-terraform/provider.tf
+++ b/compatibility-tests/compat-terraform/provider.tf
@@ -25,22 +25,53 @@ provider "aws" {
s3_use_path_style = true
endpoints {
- s3 = var.endpoint
- sqs = var.endpoint
- sns = var.endpoint
- dynamodb = var.endpoint
- lambda = var.endpoint
- iam = var.endpoint
- sts = var.endpoint
- ssm = var.endpoint
- secretsmanager = var.endpoint
- cognitoidp = var.endpoint
- rds = var.endpoint
- cloudwatch = var.endpoint
- ec2 = var.endpoint
- route53 = var.endpoint
- appautoscaling = var.endpoint
- ses = var.endpoint
- guardduty = var.endpoint
+ s3 = var.endpoint
+ sqs = var.endpoint
+ sns = var.endpoint
+ dynamodb = var.endpoint
+ lambda = var.endpoint
+ iam = var.endpoint
+ sts = var.endpoint
+ ssm = var.endpoint
+ secretsmanager = var.endpoint
+ cognitoidp = var.endpoint
+ rds = var.endpoint
+ cloudwatch = var.endpoint
+ ec2 = var.endpoint
+ route53 = var.endpoint
+ appautoscaling = var.endpoint
+ guardduty = var.endpoint
+ elasticache = var.endpoint
+ ecr = var.endpoint
+ ecs = var.endpoint
+ kms = var.endpoint
+ kinesis = var.endpoint
+ logs = var.endpoint
+ events = var.endpoint
+ sfn = var.endpoint
+ cloudformation = var.endpoint
+ eks = var.endpoint
+ codebuild = var.endpoint
+ apigateway = var.endpoint
+ apigatewayv2 = var.endpoint
+ appconfig = var.endpoint
+ appsync = var.endpoint
+ athena = var.endpoint
+ backup = var.endpoint
+ servicediscovery = var.endpoint
+ codedeploy = var.endpoint
+ acm = var.endpoint
+ ses = var.endpoint
+ scheduler = var.endpoint
+ transfer = var.endpoint
+ wafv2 = var.endpoint
+ cloudtrail = var.endpoint
+ cur = var.endpoint
+ glue = var.endpoint
+ firehose = var.endpoint
+ pipes = var.endpoint
+ batch = var.endpoint
+ neptune = var.endpoint
+ opensearch = var.endpoint
}
}
diff --git a/compatibility-tests/compat-terraform/test/terraform.bats b/compatibility-tests/compat-terraform/test/terraform.bats
index d1fddf52c5..c2beb5d620 100644
--- a/compatibility-tests/compat-terraform/test/terraform.bats
+++ b/compatibility-tests/compat-terraform/test/terraform.bats
@@ -106,6 +106,147 @@ setup() {
assert_output --partial "floci-compat"
}
+@test "Terraform: ECR repository created" {
+ run aws_cmd ecr describe-repositories --repository-names floci-compat-app
+ assert_success
+ assert_output --partial "floci-compat-app"
+}
+
+@test "Terraform: ECS cluster created" {
+ run aws_cmd ecs describe-clusters --clusters floci-compat-cluster
+ assert_success
+ assert_output --partial "floci-compat-cluster"
+ assert_output --partial "ACTIVE"
+}
+
+@test "Terraform: KMS key created" {
+ run aws_cmd kms list-keys
+ assert_success
+ [ "$(aws_cmd kms list-keys --query 'length(Keys)' --output text)" -gt 0 ]
+}
+
+@test "Terraform: Kinesis stream created" {
+ run aws_cmd kinesis describe-stream-summary --stream-name floci-compat-events
+ assert_success
+ assert_output --partial "ACTIVE"
+}
+
+@test "Terraform: CloudWatch log group created" {
+ run aws_cmd logs describe-log-groups --log-group-name-prefix /floci/compat/app
+ assert_success
+ assert_output --partial "/floci/compat/app"
+}
+
+@test "Terraform: EventBridge event bus created" {
+ run aws_cmd events describe-event-bus --name floci-compat-bus
+ assert_success
+ assert_output --partial "floci-compat-bus"
+}
+
+@test "Terraform: Step Functions state machine created" {
+ run aws_cmd stepfunctions list-state-machines
+ assert_success
+ assert_output --partial "floci-compat-state-machine"
+}
+
+@test "Terraform: CloudFormation stack created" {
+ run aws_cmd cloudformation describe-stacks --stack-name floci-compat-stack
+ assert_success
+ assert_output --partial "floci-compat-stack"
+}
+
+@test "Terraform: EKS cluster created" {
+ run aws_cmd eks describe-cluster --name floci-compat-eks
+ assert_success
+ assert_output --partial "floci-compat-eks"
+ assert_output --partial "ACTIVE"
+}
+
+@test "Terraform: API Gateway v2 HTTP API created" {
+ run aws_cmd apigatewayv2 get-apis
+ assert_success
+ assert_output --partial "floci-compat-http-api"
+}
+
+@test "Terraform: AppConfig application created" {
+ run aws_cmd appconfig list-applications
+ assert_success
+ assert_output --partial "floci-compat-appconfig"
+}
+
+@test "Terraform: Backup vault created" {
+ run aws_cmd backup describe-backup-vault --backup-vault-name floci-compat-vault
+ assert_success
+ assert_output --partial "floci-compat-vault"
+}
+
+@test "Terraform: Cloud Map namespace created" {
+ run aws_cmd servicediscovery list-namespaces
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "Terraform: CodeDeploy application created" {
+ run aws_cmd deploy get-application --application-name floci-compat-codedeploy
+ assert_success
+ assert_output --partial "floci-compat-codedeploy"
+}
+
+@test "Terraform: ACM certificate created" {
+ run aws_cmd acm list-certificates
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "Terraform: SES identity created" {
+ run aws_cmd ses get-identity-verification-attributes \
+ --identities [email protected]
+ assert_success
+ assert_output --partial "[email protected]"
+}
+
+@test "Terraform: EventBridge schedule created" {
+ run aws_cmd scheduler get-schedule --name floci-compat-schedule
+ assert_success
+ assert_output --partial "floci-compat-schedule"
+}
+
+@test "Terraform: WAFv2 web ACL created" {
+ run aws_cmd wafv2 list-web-acls --scope REGIONAL
+ assert_success
+ assert_output --partial "floci-compat-waf"
+}
+
+@test "Terraform: Cost and Usage Report created" {
+ run aws_cmd cur describe-report-definitions
+ assert_success
+ assert_output --partial "floci-compat-report"
+}
+
+@test "Terraform: AppSync GraphQL API created" {
+ run aws_cmd appsync list-graphql-apis
+ assert_success
+ assert_output --partial "floci-compat-graphql"
+}
+
+@test "Terraform: ElastiCache replication group created" {
+ run aws_cmd elasticache describe-replication-groups --replication-group-id floci-compat-cache
+ assert_success
+ assert_output --partial "floci-compat-cache"
+}
+
+@test "Terraform: Firehose delivery stream created" {
+ run aws_cmd firehose list-delivery-streams
+ assert_success
+ assert_output --partial "floci-compat-firehose-basic"
+}
+
+@test "Terraform: EventBridge pipe created" {
+ run aws_cmd pipes list-pipes
+ assert_success
+ assert_output --partial "floci-compat-pipe"
+}
+
@test "Terraform: RDS DB instance created and available" {
run aws_cmd rds describe-db-instances --db-instance-identifier floci-compat-db
assert_success
diff --git a/compatibility-tests/compat-terraform/test/test_helper/common-setup.bash b/compatibility-tests/compat-terraform/test/test_helper/common-setup.bash
index aa0ac082fa..d3009b2a3f 100644
--- a/compatibility-tests/compat-terraform/test/test_helper/common-setup.bash
+++ b/compatibility-tests/compat-terraform/test/test_helper/common-setup.bash
@@ -63,7 +63,7 @@ access_key = "test"
secret_key = "test"
skip_credentials_validation = true
skip_region_validation = true
-force_path_style = true
+use_path_style = true
dynamodb_endpoint = "${FLOCI_ENDPOINT}"
dynamodb_table = "tflock"
diff --git a/docs/getting-started/terraform.md b/docs/getting-started/terraform.md
new file mode 100644
index 0000000000..0c7e5c6489
--- /dev/null
+++ b/docs/getting-started/terraform.md
@@ -0,0 +1,144 @@
+# Terraform with Floci
+
+Terraform can use Floci as a local AWS-compatible endpoint. Terraform sends requests through the standard `hashicorp/aws` provider, while Floci stores and emulates the resources locally. No real AWS account or cloud resources are used.
+
+## Start Floci
+
+```yaml title="docker-compose.yml"
+services:
+ floci:
+ image: floci/floci:latest
+ ports:
+ - "4566:4566"
+ volumes:
+ - ./data:/app/data
+```
+
+```bash
+docker compose up -d
+```
+
+## Configure the AWS provider
+
+Create `provider.tf`:
+
+```hcl
+terraform {
+ required_providers {
+ aws = {
+ source = "hashicorp/aws"
+ version = "~> 6.0"
+ }
+ }
+}
+
+provider "aws" {
+ region = "us-east-1"
+ access_key = "test"
+ secret_key = "test"
+
+ skip_credentials_validation = true
+ skip_metadata_api_check = true
+ skip_requesting_account_id = true
+ s3_use_path_style = true
+
+ endpoints {
+ dynamodb = "http://localhost:4566"
+ secretsmanager = "http://localhost:4566"
+ s3 = "http://localhost:4566"
+ sns = "http://localhost:4566"
+ sqs = "http://localhost:4566"
+ ssm = "http://localhost:4566"
+ }
+}
+```
+
+The endpoint must be configured for every AWS service used by the Terraform configuration. See the [services overview](../services/index.md) for the services implemented by Floci.
+
+## Create local AWS resources
+
+Create `main.tf`:
+
+```hcl
+resource "aws_s3_bucket" "app" {
+ bucket = "floci-terraform-example"
+}
+
+resource "aws_sqs_queue" "jobs" {
+ name = "floci-terraform-jobs"
+}
+
+resource "aws_dynamodb_table" "items" {
+ name = "floci-terraform-items"
+ billing_mode = "PAY_PER_REQUEST"
+ hash_key = "id"
+
+ attribute {
+ name = "id"
+ type = "S"
+ }
+}
+
+resource "aws_ssm_parameter" "environment" {
+ name = "/floci/environment"
+ type = "String"
+ value = "local"
+}
+```
+
+Initialize and apply the configuration:
+
+```bash
+terraform init
+terraform validate
+terraform plan
+terraform apply
+```
+
+Verify a resource through the AWS CLI:
+
+```bash
+aws --endpoint-url http://localhost:4566 \
+ s3api head-bucket --bucket floci-terraform-example
+```
+
+Remove the local resources when finished:
+
+```bash
+terraform destroy
+```
+
+## Terraform state in Floci
+
+Terraform can keep state locally by using its default local backend. For a fully emulated AWS workflow, Floci also supports the S3 backend and DynamoDB locking used by the compatibility suite:
+
+```hcl
+terraform {
+ backend "s3" {
+ bucket = "tfstate"
+ key = "terraform.tfstate"
+ region = "us-east-1"
+ endpoint = "http://localhost:4566"
+ dynamodb_endpoint = "http://localhost:4566"
+ dynamodb_table = "tflock"
+ access_key = "test"
+ secret_key = "test"
+ skip_credentials_validation = true
+ skip_region_validation = true
+ use_path_style = true
+ }
+}
+```
+
+Create the backend resources before running `terraform init`:
+
+```bash
+aws --endpoint-url http://localhost:4566 s3api create-bucket --bucket tfstate
+aws --endpoint-url http://localhost:4566 dynamodb create-table \
+ --table-name tflock \
+ --attribute-definitions AttributeName=LockID,AttributeType=S \
+ --key-schema AttributeName=LockID,KeyType=HASH \
+ --billing-mode PAY_PER_REQUEST
+```
+
+For a complete automated example covering more services and the full lifecycle, see [`compatibility-tests/compat-terraform`](https://github.com/floci-io/floci/tree/main/compatibility-tests/compat-terraform).
diff --git a/mkdocs.yml b/mkdocs.yml
index 9de06047e0..a32fee9b88 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -60,6 +60,7 @@ nav:
- Quick Start: getting-started/quick-start.md
- Installation: getting-started/installation.md
- AWS CLI & SDK Setup: getting-started/aws-setup.md
+ - Terraform: getting-started/terraform.md
- Migrate from LocalStack: getting-started/migrate-from-localstack.md
- Configuration:
- Environment Variables: configuration/environment-variables.md