Pulumi
CloudMock works with Pulumi in three ways: the cloudmock-pulumi wrapper (simplest), the official Pulumi AWS provider with endpoint overrides (most compatible), or the native CloudMock Pulumi provider (deepest integration).
Prerequisites
Section titled “Prerequisites”- Pulumi CLI 3.0+
- CloudMock running on
localhost:4566
Option 1: cloudmock-pulumi wrapper
Section titled “Option 1: cloudmock-pulumi wrapper”cloudmock-pulumi is a drop-in replacement for the pulumi CLI that automatically configures the AWS provider to target CloudMock and uses a local state backend:
cloudmock-pulumi new typescript # scaffold a new TypeScript projectcloudmock-pulumi up # deploy against CloudMockcloudmock-pulumi preview # preview changescloudmock-pulumi destroy # tear downAll arguments are forwarded to pulumi, so -s, --diff, --yes, and other flags work as expected.
Option 2: Official AWS provider with endpoint overrides
Section titled “Option 2: Official AWS provider with endpoint overrides”Use the @pulumi/aws package and configure the provider to point at CloudMock.
TypeScript / JavaScript
Section titled “TypeScript / JavaScript”import * as aws from "@pulumi/aws";
const provider = new aws.Provider("cloudmock", { accessKey: "test", secretKey: "test", region: "us-east-1", skipCredentialsValidation: true, skipRequestingAccountId: true, endpoints: [{ s3: "http://localhost:4566", dynamodb: "http://localhost:4566", sqs: "http://localhost:4566", sns: "http://localhost:4566", lambda: "http://localhost:4566", iam: "http://localhost:4566", ecs: "http://localhost:4566", eks: "http://localhost:4566", rds: "http://localhost:4566", kms: "http://localhost:4566", secretsmanager: "http://localhost:4566", ssm: "http://localhost:4566", cloudwatch: "http://localhost:4566", cloudwatchlogs: "http://localhost:4566", }],});
const bucket = new aws.s3.Bucket("example-bucket", {}, { provider });const table = new aws.dynamodb.Table("example-table", { attributes: [{ name: "pk", type: "S" }], hashKey: "pk", billingMode: "PAY_PER_REQUEST",}, { provider });const queue = new aws.sqs.Queue("example-queue", {}, { provider });
export const bucketName = bucket.id;export const tableName = table.name;export const queueUrl = queue.url;Using Pulumi config instead of a provider object
Section titled “Using Pulumi config instead of a provider object”For projects that use the default provider, configure endpoints via pulumi config:
pulumi config set aws:accessKey testpulumi config set aws:secretKey testpulumi config set aws:region us-east-1pulumi config set aws:skipCredentialsValidation truepulumi config set aws:skipRequestingAccountId truepulumi config set aws:endpoints \ '[{"s3":"http://localhost:4566","dynamodb":"http://localhost:4566","sqs":"http://localhost:4566"}]'Python
Section titled “Python”import pulumi_aws as aws
provider = aws.Provider("cloudmock", access_key="test", secret_key="test", region="us-east-1", skip_credentials_validation=True, skip_requesting_account_id=True, endpoints=[aws.ProviderEndpointArgs( s3="http://localhost:4566", dynamodb="http://localhost:4566", sqs="http://localhost:4566", )],)
bucket = aws.s3.Bucket("example-bucket", opts=pulumi.ResourceOptions(provider=provider))provider, err := aws.NewProvider(ctx, "cloudmock", &aws.ProviderArgs{ AccessKey: pulumi.String("test"), SecretKey: pulumi.String("test"), Region: pulumi.String("us-east-1"), SkipCredentialsValidation: pulumi.Bool(true), SkipRequestingAccountId: pulumi.Bool(true), Endpoints: aws.ProviderEndpointArray{ &aws.ProviderEndpointArgs{ S3: pulumi.String("http://localhost:4566"), Dynamodb: pulumi.String("http://localhost:4566"), Sqs: pulumi.String("http://localhost:4566"), }, },})Option 3: Native CloudMock Pulumi provider
Section titled “Option 3: Native CloudMock Pulumi provider”The native CloudMock provider is pre-configured for CloudMock and does not require endpoint configuration. It exposes CloudMock-specific features like chaos controls, metric injection, and topology queries as first-class Pulumi resources.
Install
Section titled “Install”pulumi plugin install resource cloudmockOr add to your project:
npm install @cloudmock/pulumi # TypeScript / JavaScriptpip install pulumi-cloudmock # Pythongo get github.com/neureaux/cloudmock/sdk/go/cloudmock # GoUsage (TypeScript)
Section titled “Usage (TypeScript)”import * as cloudmock from "@cloudmock/pulumi";
const provider = new cloudmock.Provider("local", { endpoint: "http://localhost:4566",});
const bucket = new cloudmock.s3.Bucket("example-bucket", {}, { provider });const table = new cloudmock.dynamodb.Table("example-table", { hashKey: "pk", attributes: [{ name: "pk", type: "S" }], billingMode: "PAY_PER_REQUEST",}, { provider });State backends
Section titled “State backends”Use a local state file for development:
pulumi login --localOr use Pulumi Cloud (the default) — it works with CloudMock because the state is stored separately from AWS.
Example project
Section titled “Example project”A complete working example is in examples/pulumi-typescript/ in the repository.
Troubleshooting
Section titled “Troubleshooting”error: aws:index/provider:Provider resource ... No valid credential sources found
Set skipCredentialsValidation: true on the provider.
Resources deploy but changes are not visible
Confirm that CloudMock is running (curl http://localhost:4566/_cloudmock/health) and that the endpoint for the resource’s service is in the endpoints list.
pulumi up hangs
This is usually a network issue. Verify CloudMock is reachable at localhost:4566.