alchemy 0.2.3 → 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.
Files changed (138) hide show
  1. package/lib/ai/ark.d.ts +11 -0
  2. package/lib/ai/ark.js +86 -0
  3. package/lib/ai/client.d.ts +51 -0
  4. package/lib/ai/client.js +29 -0
  5. package/lib/ai/document.d.ts +97 -0
  6. package/lib/ai/document.js +82 -0
  7. package/lib/{docs → ai}/index.d.ts +1 -0
  8. package/lib/{docs → ai}/index.js +1 -0
  9. package/lib/ai/object.d.ts +101 -0
  10. package/lib/ai/object.js +70 -0
  11. package/lib/alchemy.d.ts +83 -2
  12. package/lib/alchemy.js +31 -3
  13. package/lib/aws/bucket.d.ts +87 -1
  14. package/lib/aws/bucket.js +48 -1
  15. package/lib/aws/function.d.ts +186 -1
  16. package/lib/aws/function.js +62 -8
  17. package/lib/aws/oidc/github-oidc-provider.d.ts +81 -0
  18. package/lib/aws/oidc/github-oidc-provider.js +68 -0
  19. package/lib/aws/oidc/oidc-provider.d.ts +14 -6
  20. package/lib/aws/oidc/oidc-provider.js +26 -5
  21. package/lib/aws/policy-attachment.d.ts +44 -1
  22. package/lib/aws/policy-attachment.js +31 -0
  23. package/lib/aws/policy.d.ts +160 -1
  24. package/lib/aws/policy.js +78 -0
  25. package/lib/aws/queue.d.ts +83 -1
  26. package/lib/aws/queue.js +39 -0
  27. package/lib/aws/role.d.ts +162 -1
  28. package/lib/aws/role.js +114 -0
  29. package/lib/aws/ses.d.ts +57 -2
  30. package/lib/aws/ses.js +42 -1
  31. package/lib/aws/table.d.ts +96 -1
  32. package/lib/aws/table.js +36 -0
  33. package/lib/cloudflare/asset-manifest.js +0 -1
  34. package/lib/cloudflare/bound.js +0 -1
  35. package/lib/cloudflare/bucket.d.ts +37 -1
  36. package/lib/cloudflare/bucket.js +36 -0
  37. package/lib/cloudflare/durable-object-namespace.d.ts +25 -0
  38. package/lib/cloudflare/durable-object-namespace.js +22 -0
  39. package/lib/cloudflare/kv-namespace.d.ts +37 -1
  40. package/lib/cloudflare/kv-namespace.js +36 -0
  41. package/lib/cloudflare/static-site.d.ts +53 -1
  42. package/lib/cloudflare/static-site.js +53 -1
  43. package/lib/cloudflare/worker-metadata.js +0 -1
  44. package/lib/cloudflare/worker.d.ts +64 -1
  45. package/lib/cloudflare/worker.js +63 -0
  46. package/lib/cloudflare/wrangler.json.d.ts +1 -1
  47. package/lib/cloudflare/zone-settings.js +0 -1
  48. package/lib/cloudflare/zone.d.ts +56 -1
  49. package/lib/cloudflare/zone.js +55 -0
  50. package/lib/destroy.js +1 -1
  51. package/lib/esbuild/bundle.d.ts +43 -4
  52. package/lib/esbuild/bundle.js +16 -0
  53. package/lib/fs/file-collection.d.ts +16 -0
  54. package/lib/fs/file-collection.js +6 -0
  55. package/lib/fs/file-ref.d.ts +14 -0
  56. package/lib/fs/file-ref.js +6 -0
  57. package/lib/fs/file.d.ts +71 -25
  58. package/lib/fs/file.js +20 -44
  59. package/lib/fs/folder.d.ts +37 -5
  60. package/lib/fs/folder.js +26 -2
  61. package/lib/fs/index.d.ts +6 -0
  62. package/lib/fs/index.js +6 -0
  63. package/lib/fs/json-file.d.ts +16 -0
  64. package/lib/fs/json-file.js +7 -0
  65. package/lib/fs/text-file.d.ts +12 -0
  66. package/lib/fs/text-file.js +7 -0
  67. package/lib/fs/typescript-file.d.ts +19 -0
  68. package/lib/fs/typescript-file.js +14 -0
  69. package/lib/fs/yaml-file.d.ts +19 -0
  70. package/lib/fs/yaml-file.js +8 -0
  71. package/lib/github/secret.d.ts +63 -2
  72. package/lib/github/secret.js +61 -1
  73. package/lib/internal/docs.d.ts +5 -0
  74. package/lib/internal/docs.js +324 -0
  75. package/lib/resource.d.ts +1 -1
  76. package/lib/secret.d.ts +67 -0
  77. package/lib/secret.js +67 -0
  78. package/lib/shadcn/component.d.ts +1 -1
  79. package/lib/stripe/price.d.ts +51 -1
  80. package/lib/stripe/price.js +50 -0
  81. package/lib/stripe/product.d.ts +39 -1
  82. package/lib/stripe/product.js +38 -0
  83. package/lib/stripe/webhook.d.ts +46 -1
  84. package/lib/stripe/webhook.js +45 -0
  85. package/lib/test/bun.d.ts +64 -0
  86. package/lib/test/bun.js +35 -3
  87. package/lib/util/serde.js +14 -0
  88. package/lib/vite/vite.d.ts +1 -1
  89. package/lib/vitepress/dependencies.d.ts +2 -6
  90. package/lib/vitepress/vitepress.d.ts +12 -1
  91. package/lib/vitepress/vitepress.js +29 -23
  92. package/package.json +8 -3
  93. package/src/ai/ark.ts +118 -0
  94. package/src/ai/client.ts +78 -0
  95. package/src/ai/document.ts +160 -0
  96. package/src/{docs → ai}/index.ts +1 -0
  97. package/src/ai/object.ts +149 -0
  98. package/src/alchemy.ts +88 -5
  99. package/src/aws/bucket.ts +111 -7
  100. package/src/aws/function.ts +231 -10
  101. package/src/aws/oidc/github-oidc-provider.ts +83 -0
  102. package/src/aws/oidc/oidc-provider.ts +39 -7
  103. package/src/aws/policy-attachment.ts +44 -1
  104. package/src/aws/policy.ts +177 -2
  105. package/src/aws/queue.ts +89 -0
  106. package/src/aws/role.ts +174 -2
  107. package/src/aws/ses.ts +56 -1
  108. package/src/aws/table.ts +103 -0
  109. package/src/cloudflare/bucket.ts +36 -0
  110. package/src/cloudflare/durable-object-namespace.ts +25 -0
  111. package/src/cloudflare/kv-namespace.ts +36 -0
  112. package/src/cloudflare/static-site.ts +53 -1
  113. package/src/cloudflare/worker.ts +63 -0
  114. package/src/cloudflare/zone.ts +55 -0
  115. package/src/destroy.ts +1 -1
  116. package/src/esbuild/bundle.ts +53 -3
  117. package/src/fs/file-collection.ts +24 -0
  118. package/src/fs/file-ref.ts +22 -0
  119. package/src/fs/file.ts +70 -77
  120. package/src/fs/folder.ts +44 -5
  121. package/src/fs/index.ts +6 -0
  122. package/src/fs/json-file.ts +23 -0
  123. package/src/fs/text-file.ts +19 -0
  124. package/src/fs/typescript-file.ts +36 -0
  125. package/src/fs/yaml-file.ts +26 -0
  126. package/src/github/secret.ts +65 -2
  127. package/src/internal/docs.ts +369 -0
  128. package/src/resource.ts +1 -1
  129. package/src/secret.ts +67 -0
  130. package/src/stripe/price.ts +50 -0
  131. package/src/stripe/product.ts +38 -0
  132. package/src/stripe/webhook.ts +45 -0
  133. package/src/test/bun.ts +83 -3
  134. package/src/util/serde.ts +17 -0
  135. package/src/vitepress/vitepress.ts +47 -26
  136. package/lib/docs/document.d.ts +0 -123
  137. package/lib/docs/document.js +0 -67
  138. package/src/docs/document.ts +0 -225
@@ -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 (default: 3600)
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 (defaults to AWS_REGION environment variable)
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 | undefined) => 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
- * Unique identifier for our trust policy statement
6
- * Used to track and remove our specific statement without affecting others
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
- export declare const PolicyAttachment: ((this: Context<PolicyAttachment>, id: string, props: PolicyAttachmentProps) => Promise<PolicyAttachment>) | (((this: any, id: string, props?: PolicyAttachmentProps | undefined) => never) & (new (_: never) => never));
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") {
@@ -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
- export declare const Policy: ((this: Context<Policy>, id: string, props: PolicyProps) => Promise<Policy>) | (((this: any, id: string, props?: PolicyProps | undefined) => never) & (new (_: never) => never));
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>);
package/lib/aws/policy.js CHANGED
@@ -1,5 +1,83 @@
1
1
  import { CreatePolicyCommand, CreatePolicyVersionCommand, DeletePolicyCommand, DeletePolicyVersionCommand, GetPolicyCommand, GetPolicyVersionCommand, IAMClient, ListPolicyVersionsCommand, NoSuchEntityException, } from "@aws-sdk/client-iam";
2
2
  import { Resource } from "../resource";
3
+ /**
4
+ * AWS IAM Policy Resource
5
+ *
6
+ * Creates and manages IAM policies that define permissions for AWS services and resources.
7
+ * Supports automatic versioning and updates when policy content changes.
8
+ *
9
+ * @example
10
+ * // Create a basic S3 bucket access policy
11
+ * const s3Policy = await Policy("bucket-access", {
12
+ * policyName: "s3-bucket-access",
13
+ * document: {
14
+ * Version: "2012-10-17",
15
+ * Statement: [{
16
+ * Effect: "Allow",
17
+ * Action: [
18
+ * "s3:GetObject",
19
+ * "s3:PutObject"
20
+ * ],
21
+ * Resource: `${bucket.arn}/*`
22
+ * }]
23
+ * }
24
+ * });
25
+ *
26
+ * @example
27
+ * // Create a policy with multiple statements and conditions
28
+ * const apiPolicy = await Policy("api-access", {
29
+ * policyName: "api-gateway-access",
30
+ * document: {
31
+ * Version: "2012-10-17",
32
+ * Statement: [
33
+ * {
34
+ * Sid: "InvokeAPI",
35
+ * Effect: "Allow",
36
+ * Action: "execute-api:Invoke",
37
+ * Resource: `${api.executionArn}/*`,
38
+ * Condition: {
39
+ * StringEquals: {
40
+ * "aws:SourceVpc": vpc.id
41
+ * }
42
+ * }
43
+ * },
44
+ * {
45
+ * Sid: "ReadLogs",
46
+ * Effect: "Allow",
47
+ * Action: [
48
+ * "logs:GetLogEvents",
49
+ * "logs:FilterLogEvents"
50
+ * ],
51
+ * Resource: `${api.logGroupArn}:*`
52
+ * }
53
+ * ]
54
+ * },
55
+ * description: "Allows invoking API Gateway endpoints and reading logs",
56
+ * tags: {
57
+ * Service: "API Gateway",
58
+ * Environment: "production"
59
+ * }
60
+ * });
61
+ *
62
+ * @example
63
+ * // Create a policy that denies access based on tags
64
+ * const denyPolicy = await Policy("deny-production", {
65
+ * policyName: "deny-production-access",
66
+ * document: {
67
+ * Version: "2012-10-17",
68
+ * Statement: [{
69
+ * Effect: "Deny",
70
+ * Action: "*",
71
+ * Resource: "*",
72
+ * Condition: {
73
+ * StringEquals: {
74
+ * "aws:ResourceTag/Environment": "production"
75
+ * }
76
+ * }
77
+ * }]
78
+ * }
79
+ * });
80
+ */
3
81
  export const Policy = Resource("iam::Policy", async function (id, props) {
4
82
  const client = new IAMClient({});
5
83
  const policyArn = `arn:aws:iam::${process.env.AWS_ACCOUNT_ID}:policy${props.path || "/"}${props.policyName}`;
@@ -1,5 +1,8 @@
1
1
  import type { Context } from "../context";
2
2
  import { Resource } from "../resource";
3
+ /**
4
+ * Properties for creating or updating an SQS queue
5
+ */
3
6
  export interface QueueProps {
4
7
  /**
5
8
  * Name of the queue
@@ -11,22 +14,101 @@ export interface QueueProps {
11
14
  * If true, the queueName must end with .fifo suffix
12
15
  */
13
16
  fifo?: boolean;
17
+ /**
18
+ * The length of time (in seconds) that a message received from a queue will be invisible to other receiving components
19
+ * Default: 30 seconds
20
+ */
14
21
  visibilityTimeout?: number;
22
+ /**
23
+ * The length of time (in seconds) for which Amazon SQS retains a message
24
+ * Default: 345600 seconds (4 days)
25
+ */
15
26
  messageRetentionPeriod?: number;
27
+ /**
28
+ * The limit of how many bytes a message can contain before Amazon SQS rejects it
29
+ * Default: 262144 bytes (256 KB)
30
+ */
16
31
  maximumMessageSize?: number;
32
+ /**
33
+ * The time in seconds that the delivery of all messages in the queue will be delayed
34
+ * Default: 0 seconds
35
+ */
17
36
  delaySeconds?: number;
37
+ /**
38
+ * The length of time (in seconds) for which a ReceiveMessage action waits for a message to arrive
39
+ * Default: 0 seconds
40
+ */
18
41
  receiveMessageWaitTimeSeconds?: number;
19
42
  /**
20
43
  * Enables content-based deduplication for FIFO queues.
21
44
  * Only applicable when fifo is true.
22
45
  */
23
46
  contentBasedDeduplication?: boolean;
47
+ /**
48
+ * Specifies whether message deduplication occurs at the message group or queue level
49
+ * Only applicable when fifo is true
50
+ */
24
51
  deduplicationScope?: "messageGroup" | "queue";
52
+ /**
53
+ * Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group
54
+ * Only applicable when fifo is true
55
+ */
25
56
  fifoThroughputLimit?: "perQueue" | "perMessageGroupId";
57
+ /**
58
+ * Resource tags for the queue
59
+ */
26
60
  tags?: Record<string, string>;
27
61
  }
62
+ /**
63
+ * Output returned after SQS queue creation/update
64
+ */
28
65
  export interface Queue extends Resource<"sqs::Queue">, QueueProps {
66
+ /**
67
+ * ARN of the queue
68
+ */
29
69
  arn: string;
70
+ /**
71
+ * URL of the queue
72
+ */
30
73
  url: string;
31
74
  }
32
- export declare const Queue: ((this: Context<Queue>, id: string, props: QueueProps) => Promise<Queue>) | (((this: any, id: string, props?: QueueProps | undefined) => never) & (new (_: never) => never));
75
+ /**
76
+ * AWS SQS Queue Resource
77
+ *
78
+ * Creates and manages Amazon SQS queues with support for both standard and FIFO queues.
79
+ * Handles queue creation, attribute configuration, and automatic cleanup of deleted queues.
80
+ *
81
+ * @example
82
+ * // Create a standard queue with custom visibility timeout
83
+ * const standardQueue = await Queue("my-queue", {
84
+ * queueName: "my-queue",
85
+ * visibilityTimeout: 30,
86
+ * tags: {
87
+ * Environment: "production"
88
+ * }
89
+ * });
90
+ *
91
+ * @example
92
+ * // Create a FIFO queue with content-based deduplication
93
+ * const fifoQueue = await Queue("orders-queue", {
94
+ * queueName: "orders-queue.fifo",
95
+ * fifo: true,
96
+ * contentBasedDeduplication: true,
97
+ * visibilityTimeout: 30,
98
+ * tags: {
99
+ * Environment: "production"
100
+ * }
101
+ * });
102
+ *
103
+ * @example
104
+ * // Create a queue with custom message retention and size
105
+ * const customQueue = await Queue("large-messages", {
106
+ * queueName: "large-messages",
107
+ * messageRetentionPeriod: 345600, // 4 days
108
+ * maximumMessageSize: 262144, // 256 KB
109
+ * visibilityTimeout: 60,
110
+ * delaySeconds: 5,
111
+ * receiveMessageWaitTimeSeconds: 20
112
+ * });
113
+ */
114
+ export declare const Queue: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Queue>, id: string, props: QueueProps) => Promise<Queue>);