WHAT YOU'LL LEARN
  • how to modify existing cloud infrastructure resources using Pulumi extensions
  • how to add new resources to the Core, API, and Admin stacks

Overview
anchor

For infrastructure changes that go beyond the declarative Infra.* components — modifying Lambda memory, adjusting IAM roles, adding custom resources — you use a Pulumi extension file.

A Pulumi extension is a TypeScript file that receives the Pulumi context for a specific stack and can modify or add resources directly. You register it in webiny.config.tsx using Infra.Core.Pulumi, Infra.Api.Pulumi, or Infra.Admin.Pulumi.

Registering a Pulumi Extension
anchor

webiny.config.tsx

Each component targets a specific stack:

  • Infra.Core.Pulumi — Core stack (DynamoDB, S3, OpenSearch, Cognito)
  • Infra.Api.Pulumi — API stack (GraphQL Lambda functions)
  • Infra.Admin.Pulumi — Admin stack (CloudFront, S3 static hosting)

Examples
anchor

Modifying an Existing Resource
anchor

Enable S3 object versioning on the File Manager bucket (Core stack):

extensions/MyCorePulumiHandler.ts

Increasing Lambda Memory Size
anchor

Increase the memory of the GraphQL Lambda function (API stack):

extensions/MyApiPulumiHandler.ts

Adding an IAM Policy
anchor

Attach a custom IAM policy to the GraphQL Lambda role to allow sending email via Amazon SES:

extensions/MyApiPulumiHandler.ts

Adjusting CloudFront Distribution Configuration
anchor

The following example adjusts the minimum TLS version for the API CloudFront distribution:

extensions/MyApiPulumiHandler.ts

Retrieving the Deployment Environment
anchor

The app parameter exposes the environment name, which you can use to apply conditional logic:

extensions/MyCorePulumiHandler.ts

Checking if the Environment Is Production
anchor

Use env.isProduction to check whether the current environment is a production environment. This is calculated based on the list of production environments defined via Infra.ProductionEnvironments:

extensions/MyApiPulumiHandler.ts

Redeploying After Changes
anchor

After modifying a Pulumi extension, redeploy the affected stack by running the webiny deploy command:

Use --env <name> to target a specific environment if needed. Only redeploy the stack that was changed.