Skip to content

Commit 764994e

Browse files
nyobeclaude
andcommitted
Updated blog post with a deployable adapter example
Co-Authored-By: Claude <[email protected]>
1 parent 3766db0 commit 764994e

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

content/blog/esc-connect/index.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Pulumi ESC has [native integrations](/docs/esc/integrations/) with popular secre
2020

2121
ESC Connect changes this by letting you build simple HTTPS adapter services using the [`external` provider](/docs/esc/integrations/dynamic-secrets/external/). Your adapter handles requests from ESC, fetches secrets from your custom source, and returns them. ESC handles authentication with signed JWT tokens, so you get fine-grained control over access without building a complete security infrastructure.
2222

23-
## Building an Adapter
23+
## Building an adapter
2424

2525
Here's an [ESC environment](/docs/esc/environments/) configuration that uses ESC Connect:
2626

@@ -35,36 +35,29 @@ values:
3535
3636
When you open this environment, ESC makes an authenticated POST request to your adapter. Your adapter validates the JWT token, fetches the secret from your source, and returns it:
3737
38-
```python
39-
# Simplified example - see docs for complete implementation
40-
class AdapterHandler(BaseHTTPRequestHandler):
41-
def do_POST(self):
42-
# Verify JWT token from Authorization header
43-
token = self.headers.get("Authorization", "").replace("Bearer ", "")
44-
claims = verify_jwt(token) # Validates signature, expiration, audience
45-
46-
# Parse request and fetch secret
47-
request = json.loads(self.rfile.read())
48-
secret_value = fetch_from_your_source(request["secretName"])
49-
50-
# Return response
51-
response = {"value": secret_value}
52-
self.send_response(200)
53-
self.wfile.write(json.dumps(response).encode())
54-
```
38+
```typescript
39+
const handler = async (event) => {
40+
// 1. Validate JWT from Authorization header
41+
const claims = await validateJWT(event.headers.Authorization);
5542

56-
Once deployed, the secrets become available in your ESC environment:
43+
// 2. Verify audience and body hash for security
44+
verifyAudience(claims.aud, event.url);
45+
verifyBodyHash(event.body, claims.body_hash);
5746

58-
```yaml
59-
environmentVariables:
60-
DB_PASSWORD: ${customSecrets.response.value}
47+
// 3. Fetch secret from your source
48+
const request = JSON.parse(event.body);
49+
const secret = await fetchFromYourSource(request.secretName);
50+
51+
// 4. Return the secret
52+
return { statusCode: 200, body: JSON.stringify(secret) };
53+
};
6154
```
6255

63-
The [documentation](/docs/esc/integrations/dynamic-secrets/external/) includes complete adapter examples with JWT verification, body hash validation, and security best practices.
56+
The [reference implementation](https://github.com/pulumi/examples/tree/master/aws-ts-esc-external-adapter-lambda) includes a complete `ESCRequestValidator` class that handles JWT verification and request integrity checking. See the [documentation](/docs/esc/integrations/dynamic-secrets/external/) for detailed security requirements and examples in other languages.
6457

65-
## Automated Rotation
58+
## Automated rotation
6659

67-
ESC Connect also supports [automated secret rotation](/docs/esc/environments/rotation/) through `fn::rotate::external`. Your rotation adapter receives the current credential state, generates new credentials, updates your target system, and returns the new state. ESC handles scheduling and maintains both current and previous credentials during transitions for zero-downtime rotation.
60+
ESC Connect also supports automated secret rotation through [`fn::rotate::external`](/docs/esc/integrations/rotated-secrets/external/). Your rotation adapter receives the current credential state, generates new credentials, updates your target system, and returns the new state. ESC handles scheduling and maintains both current and previous credentials during transitions for zero-downtime rotation.
6861

6962
```yaml
7063
values:
@@ -77,10 +70,14 @@ values:
7770
environment: production
7871
```
7972
80-
The [rotation documentation](/docs/esc/integrations/rotated-secrets/external/) covers state management, dual-secret strategies, and implementation patterns.
73+
Learn more about [secret rotation in Pulumi ESC](/docs/esc/environments/rotation/) and the [external rotator implementation patterns](/docs/esc/integrations/rotated-secrets/external/).
74+
75+
## Try it out
76+
77+
ESC Connect is available now in Pulumi ESC. We've created a [deployable reference adapter implementation](https://github.com/pulumi/examples/tree/master/aws-ts-esc-external-adapter-lambda) on AWS Lambda that demonstrates secure request validation:
8178
82-
## Try It Out
79+
[![Deploy this example with Pulumi](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-ts-esc-external-adapter-lambda/README.md)
8380
84-
ESC Connect is available now in Pulumi ESC. Check out the documentation for the [external provider](/docs/esc/integrations/dynamic-secrets/external/) and [external rotation](/docs/esc/integrations/rotated-secrets/external/) to get started. The docs include complete adapter examples with JWT verification, security best practices, and example implementations in multiple languages.
81+
Check out the documentation for the [external provider](/docs/esc/integrations/dynamic-secrets/external/) and [external rotator](/docs/esc/integrations/rotated-secrets/external/) to learn more about building production adapters.
8582
8683
To learn more about Pulumi ESC, explore the [ESC documentation](/docs/esc/) or [get started for free](/docs/esc/get-started/). If you build an adapter for a system that others might find useful, share it in the [Pulumi Community Slack](https://slack.pulumi.com) — we'd love to see what you build.

0 commit comments

Comments
 (0)