alchemy 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai/ark.d.ts +11 -0
- package/lib/ai/ark.js +86 -0
- package/lib/ai/client.d.ts +51 -0
- package/lib/ai/client.js +29 -0
- package/lib/ai/document.d.ts +97 -0
- package/lib/ai/document.js +82 -0
- package/lib/ai/index.d.ts +2 -0
- package/lib/ai/index.js +2 -0
- package/lib/ai/object.d.ts +101 -0
- package/lib/ai/object.js +70 -0
- package/lib/alchemy.d.ts +84 -2
- package/lib/alchemy.js +114 -10
- package/lib/apply.d.ts +1 -1
- package/lib/apply.js +13 -10
- package/lib/aws/bucket.d.ts +87 -1
- package/lib/aws/bucket.js +48 -1
- package/lib/aws/function.d.ts +186 -1
- package/lib/aws/function.js +62 -8
- package/lib/aws/oidc/github-oidc-provider.d.ts +81 -0
- package/lib/aws/oidc/github-oidc-provider.js +68 -0
- package/lib/aws/oidc/oidc-provider.d.ts +14 -6
- package/lib/aws/oidc/oidc-provider.js +26 -5
- package/lib/aws/policy-attachment.d.ts +44 -1
- package/lib/aws/policy-attachment.js +31 -0
- package/lib/aws/policy.d.ts +160 -1
- package/lib/aws/policy.js +78 -0
- package/lib/aws/queue.d.ts +83 -1
- package/lib/aws/queue.js +39 -0
- package/lib/aws/role.d.ts +162 -1
- package/lib/aws/role.js +114 -0
- package/lib/aws/ses.d.ts +57 -2
- package/lib/aws/ses.js +42 -1
- package/lib/aws/table.d.ts +96 -1
- package/lib/aws/table.js +36 -0
- package/lib/cloudflare/asset-manifest.js +0 -1
- package/lib/cloudflare/bound.js +0 -1
- package/lib/cloudflare/bucket.d.ts +37 -1
- package/lib/cloudflare/bucket.js +36 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +25 -0
- package/lib/cloudflare/durable-object-namespace.js +22 -0
- package/lib/cloudflare/kv-namespace.d.ts +37 -1
- package/lib/cloudflare/kv-namespace.js +36 -0
- package/lib/cloudflare/static-site.d.ts +53 -1
- package/lib/cloudflare/static-site.js +53 -1
- package/lib/cloudflare/worker-metadata.js +0 -1
- package/lib/cloudflare/worker.d.ts +64 -1
- package/lib/cloudflare/worker.js +63 -0
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/zone-settings.js +0 -1
- package/lib/cloudflare/zone.d.ts +56 -1
- package/lib/cloudflare/zone.js +55 -0
- package/lib/context.d.ts +9 -4
- package/lib/context.js +4 -2
- package/lib/destroy.js +9 -8
- package/lib/esbuild/bundle.d.ts +43 -4
- package/lib/esbuild/bundle.js +16 -0
- package/lib/fs/file-collection.d.ts +16 -0
- package/lib/fs/file-collection.js +6 -0
- package/lib/fs/file-ref.d.ts +14 -0
- package/lib/fs/file-ref.js +6 -0
- package/lib/fs/file.d.ts +78 -5
- package/lib/fs/file.js +39 -3
- package/lib/fs/folder.d.ts +37 -5
- package/lib/fs/folder.js +28 -3
- package/lib/fs/index.d.ts +6 -0
- package/lib/fs/index.js +6 -0
- package/lib/fs/json-file.d.ts +16 -0
- package/lib/fs/json-file.js +7 -0
- package/lib/fs/text-file.d.ts +12 -0
- package/lib/fs/text-file.js +7 -0
- package/lib/fs/typescript-file.d.ts +19 -0
- package/lib/fs/typescript-file.js +14 -0
- package/lib/fs/yaml-file.d.ts +19 -0
- package/lib/fs/yaml-file.js +8 -0
- package/lib/github/secret.d.ts +63 -2
- package/lib/github/secret.js +61 -1
- package/lib/internal/docs.d.ts +5 -0
- package/lib/internal/docs.js +324 -0
- package/lib/resource.d.ts +2 -2
- package/lib/resource.js +4 -0
- package/lib/scope.d.ts +1 -1
- package/lib/scope.js +6 -6
- package/lib/secret.d.ts +67 -0
- package/lib/secret.js +67 -0
- package/lib/shadcn/component.d.ts +1 -1
- package/lib/state.d.ts +1 -1
- package/lib/state.js +8 -1
- package/lib/stripe/price.d.ts +51 -1
- package/lib/stripe/price.js +50 -0
- package/lib/stripe/product.d.ts +39 -1
- package/lib/stripe/product.js +38 -0
- package/lib/stripe/webhook.d.ts +46 -1
- package/lib/stripe/webhook.js +45 -0
- package/lib/test/bun.d.ts +64 -0
- package/lib/test/bun.js +35 -3
- package/lib/util/serde.d.ts +3 -1
- package/lib/util/serde.js +20 -4
- package/lib/vite/vite.d.ts +1 -1
- package/lib/vitepress/dependencies.d.ts +12 -0
- package/lib/vitepress/dependencies.js +35 -0
- package/lib/vitepress/home-page.d.ts +133 -0
- package/lib/vitepress/home-page.js +11 -0
- package/lib/vitepress/index.d.ts +2 -0
- package/lib/vitepress/index.js +2 -0
- package/lib/vitepress/vitepress.d.ts +71 -0
- package/lib/vitepress/vitepress.js +266 -0
- package/package.json +22 -10
- package/src/ai/ark.ts +118 -0
- package/src/ai/client.ts +78 -0
- package/src/ai/document.ts +160 -0
- package/src/ai/index.ts +2 -0
- package/src/ai/object.ts +149 -0
- package/src/alchemy.ts +192 -17
- package/src/apply.ts +25 -13
- package/src/aws/bucket.ts +111 -7
- package/src/aws/function.ts +231 -10
- package/src/aws/oidc/github-oidc-provider.ts +83 -0
- package/src/aws/oidc/oidc-provider.ts +39 -7
- package/src/aws/policy-attachment.ts +44 -1
- package/src/aws/policy.ts +177 -2
- package/src/aws/queue.ts +89 -0
- package/src/aws/role.ts +174 -2
- package/src/aws/ses.ts +56 -1
- package/src/aws/table.ts +103 -0
- package/src/cloudflare/bucket.ts +36 -0
- package/src/cloudflare/durable-object-namespace.ts +25 -0
- package/src/cloudflare/kv-namespace.ts +36 -0
- package/src/cloudflare/static-site.ts +53 -1
- package/src/cloudflare/worker.ts +63 -0
- package/src/cloudflare/zone.ts +55 -0
- package/src/context.ts +30 -10
- package/src/destroy.ts +11 -8
- package/src/esbuild/bundle.ts +53 -3
- package/src/fs/file-collection.ts +24 -0
- package/src/fs/file-ref.ts +22 -0
- package/src/fs/file.ts +107 -6
- package/src/fs/folder.ts +45 -5
- package/src/fs/index.ts +6 -0
- package/src/fs/json-file.ts +23 -0
- package/src/fs/text-file.ts +19 -0
- package/src/fs/typescript-file.ts +36 -0
- package/src/fs/yaml-file.ts +26 -0
- package/src/github/secret.ts +65 -2
- package/src/internal/docs.ts +369 -0
- package/src/resource.ts +7 -2
- package/src/scope.ts +9 -9
- package/src/secret.ts +67 -0
- package/src/state.ts +9 -2
- package/src/stripe/price.ts +50 -0
- package/src/stripe/product.ts +38 -0
- package/src/stripe/webhook.ts +45 -0
- package/src/test/bun.ts +83 -3
- package/src/util/serde.ts +30 -4
- package/src/vitepress/dependencies.ts +68 -0
- package/src/vitepress/home-page.ts +166 -0
- package/src/vitepress/index.md +75 -0
- package/src/vitepress/index.ts +2 -0
- package/src/vitepress/vitepress.ts +382 -0
- package/lib/project/vite.d.ts +0 -90
- package/lib/project/vite.js +0 -228
- package/src/project/vite.ts +0 -406
package/lib/aws/function.js
CHANGED
|
@@ -3,14 +3,60 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Resource } from "../resource";
|
|
5
5
|
import { ignore } from "../util/ignore";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/**
|
|
7
|
+
* AWS Lambda Function Resource
|
|
8
|
+
*
|
|
9
|
+
* Creates and manages AWS Lambda functions with support for Node.js runtimes, custom handlers,
|
|
10
|
+
* environment variables, and function URLs. Handles deployment packaging, IAM role
|
|
11
|
+
* stabilization, and function updates.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Create a basic Lambda function with minimal configuration
|
|
15
|
+
* const basicFunction = await Function("api-handler", {
|
|
16
|
+
* functionName: "api-handler",
|
|
17
|
+
* zipPath: "./dist/api.zip",
|
|
18
|
+
* roleArn: role.arn,
|
|
19
|
+
* runtime: Runtime.nodejs20x,
|
|
20
|
+
* handler: "index.handler",
|
|
21
|
+
* tags: {
|
|
22
|
+
* Environment: "production"
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Create a function with environment variables and custom memory/timeout
|
|
28
|
+
* const configuredFunction = await Function("worker", {
|
|
29
|
+
* functionName: "worker",
|
|
30
|
+
* zipPath: "./dist/worker.zip",
|
|
31
|
+
* roleArn: role.arn,
|
|
32
|
+
* runtime: Runtime.nodejs20x,
|
|
33
|
+
* handler: "worker.process",
|
|
34
|
+
* memorySize: 512,
|
|
35
|
+
* timeout: 30,
|
|
36
|
+
* environment: {
|
|
37
|
+
* QUEUE_URL: queue.url,
|
|
38
|
+
* LOG_LEVEL: "info"
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Create a function with a public URL endpoint and CORS
|
|
44
|
+
* const apiFunction = await Function("public-api", {
|
|
45
|
+
* functionName: "public-api",
|
|
46
|
+
* zipPath: "./dist/api.zip",
|
|
47
|
+
* roleArn: role.arn,
|
|
48
|
+
* handler: "api.handler",
|
|
49
|
+
* url: {
|
|
50
|
+
* authType: "NONE",
|
|
51
|
+
* cors: {
|
|
52
|
+
* allowOrigins: ["*"],
|
|
53
|
+
* allowMethods: ["GET", "POST"],
|
|
54
|
+
* allowHeaders: ["content-type"],
|
|
55
|
+
* maxAge: 86400
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
14
60
|
export const Function = Resource("lambda::Function", async function (id, props) {
|
|
15
61
|
const client = new LambdaClient({});
|
|
16
62
|
const region = await resolveRegion(client);
|
|
@@ -172,3 +218,11 @@ async function zipCode(filePath) {
|
|
|
172
218
|
platform: "UNIX",
|
|
173
219
|
});
|
|
174
220
|
}
|
|
221
|
+
async function resolveRegion(client) {
|
|
222
|
+
const region = client.config.region;
|
|
223
|
+
if (typeof region === "string")
|
|
224
|
+
return region;
|
|
225
|
+
if (typeof region === "function")
|
|
226
|
+
return region();
|
|
227
|
+
throw new Error("Could not resolve AWS region");
|
|
228
|
+
}
|
|
@@ -1,7 +1,88 @@
|
|
|
1
1
|
import { OIDCProvider, type OIDCProviderProps } from "./oidc-provider";
|
|
2
|
+
/**
|
|
3
|
+
* Properties for configuring GitHub-specific OIDC provider
|
|
4
|
+
* Simplified version of OIDCProviderProps that omits the thumbprint
|
|
5
|
+
* since it's automatically set to GitHub's known value
|
|
6
|
+
*/
|
|
2
7
|
export interface GitHubOIDCProviderProps extends Omit<OIDCProviderProps, "thumbprint"> {
|
|
8
|
+
/**
|
|
9
|
+
* The GitHub organization or user that owns the repository
|
|
10
|
+
* Example: "my-org" or "my-username"
|
|
11
|
+
*/
|
|
3
12
|
owner: string;
|
|
13
|
+
/**
|
|
14
|
+
* The name of the GitHub repository
|
|
15
|
+
* Example: "my-repo"
|
|
16
|
+
*/
|
|
4
17
|
repository: string;
|
|
5
18
|
}
|
|
6
19
|
export type GitHubOIDCProvider = ReturnType<typeof GitHubOIDCProvider>;
|
|
20
|
+
/**
|
|
21
|
+
* GitHub-specific OIDC Provider Resource
|
|
22
|
+
*
|
|
23
|
+
* A simplified wrapper around OIDCProvider that automatically sets the correct
|
|
24
|
+
* thumbprint for GitHub Actions. This is the recommended way to set up OIDC
|
|
25
|
+
* authentication for GitHub Actions workflows.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Create a GitHub OIDC provider for all branches
|
|
29
|
+
* const provider = await GitHubOIDCProvider("github", {
|
|
30
|
+
* owner: "my-org",
|
|
31
|
+
* repository: "my-repo",
|
|
32
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions"
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Create a GitHub OIDC provider with branch and environment restrictions
|
|
37
|
+
* const provider = await GitHubOIDCProvider("github-restricted", {
|
|
38
|
+
* owner: "my-org",
|
|
39
|
+
* repository: "my-repo",
|
|
40
|
+
* branches: ["main", "prod"],
|
|
41
|
+
* environments: ["staging", "production"],
|
|
42
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions",
|
|
43
|
+
* maxSessionDuration: 7200
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Complete setup with IAM role and OIDC provider
|
|
48
|
+
* import { Role, getAccountId } from "../aws";
|
|
49
|
+
*
|
|
50
|
+
* // Get the AWS account ID
|
|
51
|
+
* const accountId = await getAccountId();
|
|
52
|
+
*
|
|
53
|
+
* // Create the IAM role that GitHub Actions will assume
|
|
54
|
+
* const githubRole = await Role("github-oidc-role", {
|
|
55
|
+
* roleName: "github-actions-role",
|
|
56
|
+
* assumeRolePolicy: {
|
|
57
|
+
* Version: "2012-10-17",
|
|
58
|
+
* Statement: [
|
|
59
|
+
* {
|
|
60
|
+
* Sid: "GitHubOIDC",
|
|
61
|
+
* Effect: "Allow",
|
|
62
|
+
* Principal: {
|
|
63
|
+
* Federated: `arn:aws:iam::${accountId}:oidc-provider/token.actions.githubusercontent.com`
|
|
64
|
+
* },
|
|
65
|
+
* Action: "sts:AssumeRoleWithWebIdentity",
|
|
66
|
+
* Condition: {
|
|
67
|
+
* StringEquals: {
|
|
68
|
+
* "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
|
|
69
|
+
* },
|
|
70
|
+
* StringLike: {
|
|
71
|
+
* "token.actions.githubusercontent.com:sub": "repo:my-org/my-repo:*"
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ]
|
|
76
|
+
* },
|
|
77
|
+
* // Add required managed policies or inline policies for your use case
|
|
78
|
+
* managedPolicyArns: ["arn:aws:iam::aws:policy/ReadOnlyAccess"]
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* // Create the OIDC provider using the role
|
|
82
|
+
* const provider = await GitHubOIDCProvider("github-oidc", {
|
|
83
|
+
* owner: "my-org",
|
|
84
|
+
* repository: "my-repo",
|
|
85
|
+
* roleArn: githubRole.arn
|
|
86
|
+
* });
|
|
87
|
+
*/
|
|
7
88
|
export declare const GitHubOIDCProvider: (id: string, props: GitHubOIDCProviderProps) => Promise<OIDCProvider>;
|
|
@@ -5,6 +5,74 @@ import { OIDCProvider } from "./oidc-provider";
|
|
|
5
5
|
* @see https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#adding-the-identity-provider-to-aws
|
|
6
6
|
*/
|
|
7
7
|
const DEFAULT_GITHUB_THUMBPRINT = "6938fd4d98bab03faadb97b34396831e3780aea1";
|
|
8
|
+
/**
|
|
9
|
+
* GitHub-specific OIDC Provider Resource
|
|
10
|
+
*
|
|
11
|
+
* A simplified wrapper around OIDCProvider that automatically sets the correct
|
|
12
|
+
* thumbprint for GitHub Actions. This is the recommended way to set up OIDC
|
|
13
|
+
* authentication for GitHub Actions workflows.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Create a GitHub OIDC provider for all branches
|
|
17
|
+
* const provider = await GitHubOIDCProvider("github", {
|
|
18
|
+
* owner: "my-org",
|
|
19
|
+
* repository: "my-repo",
|
|
20
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions"
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Create a GitHub OIDC provider with branch and environment restrictions
|
|
25
|
+
* const provider = await GitHubOIDCProvider("github-restricted", {
|
|
26
|
+
* owner: "my-org",
|
|
27
|
+
* repository: "my-repo",
|
|
28
|
+
* branches: ["main", "prod"],
|
|
29
|
+
* environments: ["staging", "production"],
|
|
30
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions",
|
|
31
|
+
* maxSessionDuration: 7200
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Complete setup with IAM role and OIDC provider
|
|
36
|
+
* import { Role, getAccountId } from "../aws";
|
|
37
|
+
*
|
|
38
|
+
* // Get the AWS account ID
|
|
39
|
+
* const accountId = await getAccountId();
|
|
40
|
+
*
|
|
41
|
+
* // Create the IAM role that GitHub Actions will assume
|
|
42
|
+
* const githubRole = await Role("github-oidc-role", {
|
|
43
|
+
* roleName: "github-actions-role",
|
|
44
|
+
* assumeRolePolicy: {
|
|
45
|
+
* Version: "2012-10-17",
|
|
46
|
+
* Statement: [
|
|
47
|
+
* {
|
|
48
|
+
* Sid: "GitHubOIDC",
|
|
49
|
+
* Effect: "Allow",
|
|
50
|
+
* Principal: {
|
|
51
|
+
* Federated: `arn:aws:iam::${accountId}:oidc-provider/token.actions.githubusercontent.com`
|
|
52
|
+
* },
|
|
53
|
+
* Action: "sts:AssumeRoleWithWebIdentity",
|
|
54
|
+
* Condition: {
|
|
55
|
+
* StringEquals: {
|
|
56
|
+
* "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
|
|
57
|
+
* },
|
|
58
|
+
* StringLike: {
|
|
59
|
+
* "token.actions.githubusercontent.com:sub": "repo:my-org/my-repo:*"
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ]
|
|
64
|
+
* },
|
|
65
|
+
* // Add required managed policies or inline policies for your use case
|
|
66
|
+
* managedPolicyArns: ["arn:aws:iam::aws:policy/ReadOnlyAccess"]
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Create the OIDC provider using the role
|
|
70
|
+
* const provider = await GitHubOIDCProvider("github-oidc", {
|
|
71
|
+
* owner: "my-org",
|
|
72
|
+
* repository: "my-repo",
|
|
73
|
+
* roleArn: githubRole.arn
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
8
76
|
export const GitHubOIDCProvider = async (id, props) => {
|
|
9
77
|
return OIDCProvider(id, {
|
|
10
78
|
owner: props.owner,
|
|
@@ -6,36 +6,45 @@ import { Resource } from "../../resource";
|
|
|
6
6
|
export interface OIDCProviderProps {
|
|
7
7
|
/**
|
|
8
8
|
* The GitHub organization or user that owns the repository
|
|
9
|
+
* Example: "my-org" or "my-username"
|
|
9
10
|
*/
|
|
10
11
|
owner: string;
|
|
11
12
|
/**
|
|
12
13
|
* The name of the GitHub repository
|
|
14
|
+
* Example: "my-repo"
|
|
13
15
|
*/
|
|
14
16
|
repository: string;
|
|
15
17
|
/**
|
|
16
18
|
* Optional list of branches to restrict access to
|
|
17
19
|
* If not provided, all branches will be allowed
|
|
20
|
+
* Example: ["main", "prod"]
|
|
18
21
|
*/
|
|
19
22
|
branches?: string[];
|
|
20
23
|
/**
|
|
21
24
|
* Optional list of environments to restrict access to
|
|
22
25
|
* If not provided, all environments will be allowed
|
|
26
|
+
* Example: ["staging", "production"]
|
|
23
27
|
*/
|
|
24
28
|
environments?: string[];
|
|
25
29
|
/**
|
|
26
30
|
* The ARN of the IAM role to be assumed
|
|
31
|
+
* Format: arn:aws:iam::account-id:role/role-name
|
|
27
32
|
*/
|
|
28
33
|
roleArn: string;
|
|
29
34
|
/**
|
|
30
|
-
* Optional maximum session duration in seconds
|
|
35
|
+
* Optional maximum session duration in seconds
|
|
36
|
+
* Default: 3600 (1 hour)
|
|
37
|
+
* Range: 900-43200 seconds (15 minutes to 12 hours)
|
|
31
38
|
*/
|
|
32
39
|
maxSessionDuration?: number;
|
|
33
40
|
/**
|
|
34
41
|
* Thumbprint for the OIDC provider
|
|
42
|
+
* Used to verify the identity provider's server certificate
|
|
35
43
|
*/
|
|
36
44
|
thumbprint: string;
|
|
37
45
|
/**
|
|
38
|
-
* Optional AWS region
|
|
46
|
+
* Optional AWS region
|
|
47
|
+
* @default AWS_REGION environment variable
|
|
39
48
|
*/
|
|
40
49
|
region?: string;
|
|
41
50
|
}
|
|
@@ -45,14 +54,13 @@ export interface OIDCProviderProps {
|
|
|
45
54
|
export interface OIDCProvider extends Resource<"aws::OIDCProvider">, OIDCProviderProps {
|
|
46
55
|
/**
|
|
47
56
|
* The ARN of the OIDC provider
|
|
57
|
+
* Format: arn:aws:iam::account-id:oidc-provider/token.actions.githubusercontent.com
|
|
48
58
|
*/
|
|
49
59
|
providerArn: string;
|
|
50
60
|
/**
|
|
51
61
|
* Time at which the provider was created
|
|
62
|
+
* Unix timestamp in milliseconds
|
|
52
63
|
*/
|
|
53
64
|
createdAt: number;
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
* Resource for configuring AWS OIDC provider for GitHub Actions
|
|
57
|
-
*/
|
|
58
|
-
export declare const OIDCProvider: ((this: Context<OIDCProvider>, id: string, props: OIDCProviderProps) => Promise<OIDCProvider>) | (((this: any, id: string, props: OIDCProviderProps) => never) & (new (_: never) => never));
|
|
66
|
+
export declare const OIDCProvider: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<OIDCProvider>, id: string, props: OIDCProviderProps) => Promise<OIDCProvider>);
|
|
@@ -2,13 +2,34 @@ import { CreateOpenIDConnectProviderCommand, DeleteOpenIDConnectProviderCommand,
|
|
|
2
2
|
import { Resource } from "../../resource";
|
|
3
3
|
import { getAccountId } from "../account-id";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* AWS OIDC Provider Resource for GitHub Actions
|
|
6
|
+
*
|
|
7
|
+
* Creates and manages an OpenID Connect (OIDC) identity provider in AWS IAM
|
|
8
|
+
* for GitHub Actions workflows. This enables secure, token-based authentication
|
|
9
|
+
* between GitHub Actions and AWS without storing long-term credentials.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Create an OIDC provider for all branches
|
|
13
|
+
* const provider = await OIDCProvider("github", {
|
|
14
|
+
* owner: "my-org",
|
|
15
|
+
* repository: "my-repo",
|
|
16
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions",
|
|
17
|
+
* thumbprint: "6938fd4d98bab03faadb97b34396831e3780aea1"
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Create an OIDC provider restricted to specific branches and environments
|
|
22
|
+
* const provider = await OIDCProvider("github-restricted", {
|
|
23
|
+
* owner: "my-org",
|
|
24
|
+
* repository: "my-repo",
|
|
25
|
+
* branches: ["main", "prod"],
|
|
26
|
+
* environments: ["staging", "production"],
|
|
27
|
+
* roleArn: "arn:aws:iam::123456789012:role/github-actions",
|
|
28
|
+
* thumbprint: "6938fd4d98bab03faadb97b34396831e3780aea1",
|
|
29
|
+
* maxSessionDuration: 7200
|
|
30
|
+
* });
|
|
7
31
|
*/
|
|
8
32
|
const TRUST_POLICY_SID = "GitHubOIDCTrust";
|
|
9
|
-
/**
|
|
10
|
-
* Resource for configuring AWS OIDC provider for GitHub Actions
|
|
11
|
-
*/
|
|
12
33
|
export const OIDCProvider = Resource("aws::OIDCProvider", async function (id, props) {
|
|
13
34
|
// Initialize AWS SDK client
|
|
14
35
|
const client = new IAMClient({
|
|
@@ -1,9 +1,52 @@
|
|
|
1
1
|
import type { Context } from "../context";
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
|
+
/**
|
|
4
|
+
* Properties for creating or updating a policy attachment
|
|
5
|
+
*/
|
|
3
6
|
export interface PolicyAttachmentProps {
|
|
7
|
+
/**
|
|
8
|
+
* ARN of the IAM policy to attach
|
|
9
|
+
*/
|
|
4
10
|
policyArn: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the IAM role to attach the policy to
|
|
13
|
+
*/
|
|
5
14
|
roleName: string;
|
|
6
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Output returned after policy attachment creation/update
|
|
18
|
+
*/
|
|
7
19
|
export interface PolicyAttachment extends Resource<"iam::PolicyAttachment">, PolicyAttachmentProps {
|
|
8
20
|
}
|
|
9
|
-
|
|
21
|
+
/**
|
|
22
|
+
* AWS IAM Policy Attachment Resource
|
|
23
|
+
*
|
|
24
|
+
* Attaches an IAM policy to a role, enabling the role to use the permissions defined in the policy.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Attach an AWS managed policy to a role
|
|
28
|
+
* const adminAccess = await PolicyAttachment("admin-policy", {
|
|
29
|
+
* policyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
|
|
30
|
+
* roleName: role.name
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Attach a custom policy to a role
|
|
35
|
+
* const customPolicy = await PolicyAttachment("custom-policy", {
|
|
36
|
+
* policyArn: policy.arn,
|
|
37
|
+
* roleName: role.name
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Attach multiple policies to a role
|
|
42
|
+
* const s3Access = await PolicyAttachment("s3-access", {
|
|
43
|
+
* policyArn: "arn:aws:iam::aws:policy/AmazonS3FullAccess",
|
|
44
|
+
* roleName: role.name
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* const sqsAccess = await PolicyAttachment("sqs-access", {
|
|
48
|
+
* policyArn: "arn:aws:iam::aws:policy/AmazonSQSFullAccess",
|
|
49
|
+
* roleName: role.name
|
|
50
|
+
* });
|
|
51
|
+
*/
|
|
52
|
+
export declare const PolicyAttachment: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<PolicyAttachment>, id: string, props: PolicyAttachmentProps) => Promise<PolicyAttachment>);
|
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import { AttachRolePolicyCommand, DetachRolePolicyCommand, IAMClient, NoSuchEntityException, } from "@aws-sdk/client-iam";
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
3
|
import { ignore } from "../util/ignore";
|
|
4
|
+
/**
|
|
5
|
+
* AWS IAM Policy Attachment Resource
|
|
6
|
+
*
|
|
7
|
+
* Attaches an IAM policy to a role, enabling the role to use the permissions defined in the policy.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Attach an AWS managed policy to a role
|
|
11
|
+
* const adminAccess = await PolicyAttachment("admin-policy", {
|
|
12
|
+
* policyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
|
|
13
|
+
* roleName: role.name
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Attach a custom policy to a role
|
|
18
|
+
* const customPolicy = await PolicyAttachment("custom-policy", {
|
|
19
|
+
* policyArn: policy.arn,
|
|
20
|
+
* roleName: role.name
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Attach multiple policies to a role
|
|
25
|
+
* const s3Access = await PolicyAttachment("s3-access", {
|
|
26
|
+
* policyArn: "arn:aws:iam::aws:policy/AmazonS3FullAccess",
|
|
27
|
+
* roleName: role.name
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const sqsAccess = await PolicyAttachment("sqs-access", {
|
|
31
|
+
* policyArn: "arn:aws:iam::aws:policy/AmazonSQSFullAccess",
|
|
32
|
+
* roleName: role.name
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
4
35
|
export const PolicyAttachment = Resource("iam::PolicyAttachment", async function (id, props) {
|
|
5
36
|
const client = new IAMClient({});
|
|
6
37
|
if (this.phase === "delete") {
|
package/lib/aws/policy.d.ts
CHANGED
|
@@ -1,34 +1,193 @@
|
|
|
1
1
|
import type { Context } from "../context";
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
|
+
/**
|
|
4
|
+
* Type of effect for a policy statement
|
|
5
|
+
*/
|
|
3
6
|
export type Effect = "Allow" | "Deny";
|
|
7
|
+
/**
|
|
8
|
+
* A single statement within an IAM policy document
|
|
9
|
+
*/
|
|
4
10
|
export interface PolicyStatement {
|
|
11
|
+
/**
|
|
12
|
+
* Optional identifier for the statement
|
|
13
|
+
*/
|
|
5
14
|
Sid?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to allow or deny the specified actions
|
|
17
|
+
*/
|
|
6
18
|
Effect: Effect;
|
|
19
|
+
/**
|
|
20
|
+
* Actions that the policy allows or denies
|
|
21
|
+
*/
|
|
7
22
|
Action: string | string[];
|
|
23
|
+
/**
|
|
24
|
+
* Resources that the policy applies to
|
|
25
|
+
*/
|
|
8
26
|
Resource?: string | string[];
|
|
27
|
+
/**
|
|
28
|
+
* Additional conditions for when the policy applies
|
|
29
|
+
*/
|
|
9
30
|
Condition?: Record<string, Record<string, string | string[]>>;
|
|
31
|
+
/**
|
|
32
|
+
* AWS principals that the policy applies to
|
|
33
|
+
*/
|
|
10
34
|
Principal?: Record<string, string | string[]>;
|
|
35
|
+
/**
|
|
36
|
+
* AWS principals that the policy explicitly does not apply to
|
|
37
|
+
*/
|
|
11
38
|
NotPrincipal?: Record<string, string | string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Actions that are explicitly not included in this statement
|
|
41
|
+
*/
|
|
12
42
|
NotAction?: string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* Resources that are explicitly not included in this statement
|
|
45
|
+
*/
|
|
13
46
|
NotResource?: string | string[];
|
|
14
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* An IAM policy document containing one or more statements
|
|
50
|
+
*/
|
|
15
51
|
export interface PolicyDocument {
|
|
52
|
+
/**
|
|
53
|
+
* Policy language version (must be "2012-10-17")
|
|
54
|
+
*/
|
|
16
55
|
Version: "2012-10-17";
|
|
56
|
+
/**
|
|
57
|
+
* List of policy statements
|
|
58
|
+
*/
|
|
17
59
|
Statement: PolicyStatement[];
|
|
18
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Properties for creating or updating an IAM policy
|
|
63
|
+
*/
|
|
19
64
|
export interface PolicyProps {
|
|
65
|
+
/**
|
|
66
|
+
* Name of the policy
|
|
67
|
+
*/
|
|
20
68
|
policyName: string;
|
|
69
|
+
/**
|
|
70
|
+
* Policy document defining the permissions
|
|
71
|
+
*/
|
|
21
72
|
document: PolicyDocument;
|
|
73
|
+
/**
|
|
74
|
+
* Optional description of the policy's purpose
|
|
75
|
+
*/
|
|
22
76
|
description?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Optional path prefix for the policy
|
|
79
|
+
*/
|
|
23
80
|
path?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional resource tags
|
|
83
|
+
*/
|
|
24
84
|
tags?: Record<string, string>;
|
|
25
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Output returned after IAM policy creation/update
|
|
88
|
+
*/
|
|
26
89
|
export interface Policy extends Resource<"iam::Policy">, PolicyProps {
|
|
90
|
+
/**
|
|
91
|
+
* ARN of the policy
|
|
92
|
+
*/
|
|
27
93
|
arn: string;
|
|
94
|
+
/**
|
|
95
|
+
* ID of the default policy version
|
|
96
|
+
*/
|
|
28
97
|
defaultVersionId: string;
|
|
98
|
+
/**
|
|
99
|
+
* Number of entities the policy is attached to
|
|
100
|
+
*/
|
|
29
101
|
attachmentCount: number;
|
|
102
|
+
/**
|
|
103
|
+
* When the policy was created
|
|
104
|
+
*/
|
|
30
105
|
createDate: Date;
|
|
106
|
+
/**
|
|
107
|
+
* When the policy was last updated
|
|
108
|
+
*/
|
|
31
109
|
updateDate: Date;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the policy can be attached to IAM users/roles
|
|
112
|
+
*/
|
|
32
113
|
isAttachable: boolean;
|
|
33
114
|
}
|
|
34
|
-
|
|
115
|
+
/**
|
|
116
|
+
* AWS IAM Policy Resource
|
|
117
|
+
*
|
|
118
|
+
* Creates and manages IAM policies that define permissions for AWS services and resources.
|
|
119
|
+
* Supports automatic versioning and updates when policy content changes.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Create a basic S3 bucket access policy
|
|
123
|
+
* const s3Policy = await Policy("bucket-access", {
|
|
124
|
+
* policyName: "s3-bucket-access",
|
|
125
|
+
* document: {
|
|
126
|
+
* Version: "2012-10-17",
|
|
127
|
+
* Statement: [{
|
|
128
|
+
* Effect: "Allow",
|
|
129
|
+
* Action: [
|
|
130
|
+
* "s3:GetObject",
|
|
131
|
+
* "s3:PutObject"
|
|
132
|
+
* ],
|
|
133
|
+
* Resource: `${bucket.arn}/*`
|
|
134
|
+
* }]
|
|
135
|
+
* }
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* // Create a policy with multiple statements and conditions
|
|
140
|
+
* const apiPolicy = await Policy("api-access", {
|
|
141
|
+
* policyName: "api-gateway-access",
|
|
142
|
+
* document: {
|
|
143
|
+
* Version: "2012-10-17",
|
|
144
|
+
* Statement: [
|
|
145
|
+
* {
|
|
146
|
+
* Sid: "InvokeAPI",
|
|
147
|
+
* Effect: "Allow",
|
|
148
|
+
* Action: "execute-api:Invoke",
|
|
149
|
+
* Resource: `${api.executionArn}/*`,
|
|
150
|
+
* Condition: {
|
|
151
|
+
* StringEquals: {
|
|
152
|
+
* "aws:SourceVpc": vpc.id
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
* },
|
|
156
|
+
* {
|
|
157
|
+
* Sid: "ReadLogs",
|
|
158
|
+
* Effect: "Allow",
|
|
159
|
+
* Action: [
|
|
160
|
+
* "logs:GetLogEvents",
|
|
161
|
+
* "logs:FilterLogEvents"
|
|
162
|
+
* ],
|
|
163
|
+
* Resource: `${api.logGroupArn}:*`
|
|
164
|
+
* }
|
|
165
|
+
* ]
|
|
166
|
+
* },
|
|
167
|
+
* description: "Allows invoking API Gateway endpoints and reading logs",
|
|
168
|
+
* tags: {
|
|
169
|
+
* Service: "API Gateway",
|
|
170
|
+
* Environment: "production"
|
|
171
|
+
* }
|
|
172
|
+
* });
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // Create a policy that denies access based on tags
|
|
176
|
+
* const denyPolicy = await Policy("deny-production", {
|
|
177
|
+
* policyName: "deny-production-access",
|
|
178
|
+
* document: {
|
|
179
|
+
* Version: "2012-10-17",
|
|
180
|
+
* Statement: [{
|
|
181
|
+
* Effect: "Deny",
|
|
182
|
+
* Action: "*",
|
|
183
|
+
* Resource: "*",
|
|
184
|
+
* Condition: {
|
|
185
|
+
* StringEquals: {
|
|
186
|
+
* "aws:ResourceTag/Environment": "production"
|
|
187
|
+
* }
|
|
188
|
+
* }
|
|
189
|
+
* }]
|
|
190
|
+
* }
|
|
191
|
+
* });
|
|
192
|
+
*/
|
|
193
|
+
export declare const Policy: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Policy>, id: string, props: PolicyProps) => Promise<Policy>);
|