alchemy 0.1.18 → 0.2.0
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/alchemy.d.ts +67 -0
- package/lib/alchemy.js +40 -0
- package/lib/apply.d.ts +3 -20
- package/lib/apply.js +86 -82
- package/lib/aws/account-id.d.ts +0 -1
- package/lib/aws/account-id.js +0 -1
- package/lib/aws/bucket.d.ts +4 -7
- package/lib/aws/bucket.js +8 -12
- package/lib/aws/function.d.ts +4 -7
- package/lib/aws/function.js +9 -30
- package/lib/aws/index.d.ts +1 -1
- package/lib/aws/index.js +1 -1
- package/lib/aws/oidc/github-oidc-provider.d.ts +2 -6
- package/lib/aws/oidc/github-oidc-provider.js +10 -15
- package/lib/aws/oidc/index.d.ts +0 -1
- package/lib/aws/oidc/index.js +0 -1
- package/lib/aws/oidc/oidc-provider.d.ts +4 -6
- package/lib/aws/oidc/oidc-provider.js +9 -11
- package/lib/aws/policy-attachment.d.ts +9 -0
- package/lib/aws/policy-attachment.js +20 -0
- package/lib/aws/policy.d.ts +4 -16
- package/lib/aws/policy.js +9 -40
- package/lib/aws/queue.d.ts +4 -34
- package/lib/aws/queue.js +10 -20
- package/lib/aws/role.d.ts +4 -7
- package/lib/aws/role.js +17 -26
- package/lib/aws/ses.d.ts +4 -10
- package/lib/aws/ses.js +118 -131
- package/lib/aws/table.d.ts +4 -7
- package/lib/aws/table.js +8 -11
- package/lib/cloudflare/api.d.ts +0 -1
- package/lib/cloudflare/api.js +0 -1
- package/lib/cloudflare/asset-manifest.d.ts +0 -1
- package/lib/cloudflare/asset-manifest.js +0 -1
- package/lib/cloudflare/auth.d.ts +0 -1
- package/lib/cloudflare/auth.js +0 -1
- package/lib/cloudflare/bindings.d.ts +1 -1
- package/lib/cloudflare/bindings.js +3 -2
- package/lib/cloudflare/bound.d.ts +0 -1
- package/lib/cloudflare/bound.js +0 -1
- package/lib/cloudflare/bucket.d.ts +7 -15
- package/lib/cloudflare/bucket.js +12 -19
- package/lib/cloudflare/durable-object-namespace.d.ts +0 -3
- package/lib/cloudflare/durable-object-namespace.js +0 -4
- package/lib/cloudflare/generate-asset-manifest.d.ts +0 -1
- package/lib/cloudflare/generate-asset-manifest.js +1 -2
- package/lib/cloudflare/index.d.ts +0 -1
- package/lib/cloudflare/index.js +0 -1
- package/lib/cloudflare/kv-namespace.d.ts +6 -9
- package/lib/cloudflare/kv-namespace.js +16 -20
- package/lib/cloudflare/state.d.ts +0 -1
- package/lib/cloudflare/state.js +0 -1
- package/lib/cloudflare/static-site-router.d.ts +0 -1
- package/lib/cloudflare/static-site-router.js +0 -4
- package/lib/cloudflare/static-site.d.ts +5 -11
- package/lib/cloudflare/static-site.js +16 -28
- package/lib/cloudflare/types.d.ts +0 -1
- package/lib/cloudflare/types.js +0 -1
- package/lib/cloudflare/upload-asset-manifest.d.ts +0 -1
- package/lib/cloudflare/upload-asset-manifest.js +0 -1
- package/lib/cloudflare/worker-metadata.d.ts +0 -1
- package/lib/cloudflare/worker-metadata.js +0 -1
- package/lib/cloudflare/worker-migration.d.ts +0 -1
- package/lib/cloudflare/worker-migration.js +0 -1
- package/lib/cloudflare/worker.d.ts +8 -14
- package/lib/cloudflare/worker.js +37 -49
- package/lib/context.d.ts +58 -0
- package/lib/context.js +36 -0
- package/lib/destroy.d.ts +10 -13
- package/lib/destroy.js +104 -43
- package/lib/{esbuild.d.ts → esbuild/bundle.d.ts} +4 -18
- package/lib/{esbuild.js → esbuild/bundle.js} +10 -24
- package/lib/esbuild/index.d.ts +1 -0
- package/lib/esbuild/index.js +1 -0
- package/lib/fs/file.d.ts +13 -0
- package/lib/fs/file.js +20 -0
- package/lib/fs/folder.d.ts +10 -0
- package/lib/fs/folder.js +16 -0
- package/lib/fs/index.d.ts +2 -0
- package/lib/fs/index.js +2 -0
- package/lib/github/client.d.ts +0 -1
- package/lib/github/client.js +0 -1
- package/lib/github/index.d.ts +0 -1
- package/lib/github/index.js +0 -1
- package/lib/github/secret.d.ts +4 -6
- package/lib/github/secret.js +10 -12
- package/lib/index.d.ts +6 -10
- package/lib/index.js +5 -9
- package/lib/resource.d.ts +34 -62
- package/lib/resource.js +29 -270
- package/lib/scope.d.ts +35 -14
- package/lib/scope.js +78 -23
- package/lib/secret.d.ts +2 -7
- package/lib/secret.js +7 -20
- package/lib/state.d.ts +14 -10
- package/lib/state.js +15 -14
- package/lib/stripe/index.d.ts +0 -1
- package/lib/stripe/index.js +0 -1
- package/lib/stripe/price.d.ts +4 -5
- package/lib/stripe/price.js +10 -20
- package/lib/stripe/product.d.ts +4 -5
- package/lib/stripe/product.js +10 -20
- package/lib/stripe/webhook.d.ts +4 -6
- package/lib/stripe/webhook.js +12 -25
- package/lib/test/bun.d.ts +19 -0
- package/lib/test/bun.js +55 -0
- package/lib/{utils → util}/content-type.d.ts +0 -1
- package/lib/{utils → util}/content-type.js +0 -1
- package/lib/{encrypt.d.ts → util/encrypt.d.ts} +0 -1
- package/lib/{encrypt.js → util/encrypt.js} +0 -1
- package/lib/{error.d.ts → util/ignore.d.ts} +0 -1
- package/lib/{error.js → util/ignore.js} +0 -1
- package/lib/{utils → util}/retry.d.ts +0 -1
- package/lib/{utils → util}/retry.js +0 -1
- package/lib/util/serde.d.ts +3 -0
- package/lib/{serde.js → util/serde.js} +19 -10
- package/lib/util/slugify.d.ts +1 -0
- package/lib/util/slugify.js +3 -0
- package/package.json +5 -4
- package/src/alchemy.ts +120 -0
- package/src/apply.ts +109 -114
- package/src/aws/bucket.ts +11 -14
- package/src/aws/function.ts +13 -33
- package/src/aws/index.ts +1 -0
- package/src/aws/oidc/github-oidc-provider.ts +14 -19
- package/src/aws/oidc/oidc-provider.ts +19 -12
- package/src/aws/policy-attachment.ts +51 -0
- package/src/aws/policy.ts +15 -60
- package/src/aws/queue.ts +17 -21
- package/src/aws/role.ts +25 -28
- package/src/aws/ses.ts +150 -164
- package/src/aws/table.ts +15 -15
- package/src/cloudflare/bindings.ts +8 -0
- package/src/cloudflare/bucket.ts +39 -47
- package/src/cloudflare/durable-object-namespace.ts +0 -10
- package/src/cloudflare/generate-asset-manifest.ts +1 -1
- package/src/cloudflare/kv-namespace.ts +35 -33
- package/src/cloudflare/static-site-router.ts +0 -3
- package/src/cloudflare/static-site.ts +44 -60
- package/src/cloudflare/worker.ts +105 -111
- package/src/context.ts +122 -0
- package/src/destroy.ts +124 -73
- package/src/{esbuild.ts → esbuild/bundle.ts} +16 -28
- package/src/esbuild/index.ts +1 -0
- package/src/fs/file.ts +39 -0
- package/src/fs/folder.ts +32 -0
- package/src/fs/index.ts +2 -0
- package/src/github/secret.ts +19 -16
- package/src/index.ts +7 -15
- package/src/resource.ts +101 -462
- package/src/scope.ts +101 -36
- package/src/secret.ts +9 -32
- package/src/state.ts +30 -21
- package/src/stripe/price.ts +17 -22
- package/src/stripe/product.ts +17 -22
- package/src/stripe/webhook.ts +21 -27
- package/src/test/bun.ts +105 -0
- package/src/util/serde.ts +53 -0
- package/src/util/slugify.ts +3 -0
- package/lib/$.d.ts +0 -12
- package/lib/$.d.ts.map +0 -1
- package/lib/$.js +0 -42
- package/lib/$.js.map +0 -1
- package/lib/alchemize.d.ts +0 -47
- package/lib/alchemize.d.ts.map +0 -1
- package/lib/alchemize.js +0 -116
- package/lib/alchemize.js.map +0 -1
- package/lib/apply.d.ts.map +0 -1
- package/lib/apply.js.map +0 -1
- package/lib/aws/account-id.d.ts.map +0 -1
- package/lib/aws/account-id.js.map +0 -1
- package/lib/aws/bucket.d.ts.map +0 -1
- package/lib/aws/bucket.js.map +0 -1
- package/lib/aws/function.d.ts.map +0 -1
- package/lib/aws/function.js.map +0 -1
- package/lib/aws/index.d.ts.map +0 -1
- package/lib/aws/index.js.map +0 -1
- package/lib/aws/oidc/github-oidc-provider.d.ts.map +0 -1
- package/lib/aws/oidc/github-oidc-provider.js.map +0 -1
- package/lib/aws/oidc/index.d.ts.map +0 -1
- package/lib/aws/oidc/index.js.map +0 -1
- package/lib/aws/oidc/oidc-provider.d.ts.map +0 -1
- package/lib/aws/oidc/oidc-provider.js.map +0 -1
- package/lib/aws/policy.d.ts.map +0 -1
- package/lib/aws/policy.js.map +0 -1
- package/lib/aws/queue.d.ts.map +0 -1
- package/lib/aws/queue.js.map +0 -1
- package/lib/aws/role.d.ts.map +0 -1
- package/lib/aws/role.js.map +0 -1
- package/lib/aws/ses.d.ts.map +0 -1
- package/lib/aws/ses.js.map +0 -1
- package/lib/aws/table.d.ts.map +0 -1
- package/lib/aws/table.js.map +0 -1
- package/lib/cloudflare/api.d.ts.map +0 -1
- package/lib/cloudflare/api.js.map +0 -1
- package/lib/cloudflare/asset-manifest.d.ts.map +0 -1
- package/lib/cloudflare/asset-manifest.js.map +0 -1
- package/lib/cloudflare/auth.d.ts.map +0 -1
- package/lib/cloudflare/auth.js.map +0 -1
- package/lib/cloudflare/bindings.d.ts.map +0 -1
- package/lib/cloudflare/bindings.js.map +0 -1
- package/lib/cloudflare/bound.d.ts.map +0 -1
- package/lib/cloudflare/bound.js.map +0 -1
- package/lib/cloudflare/bucket.d.ts.map +0 -1
- package/lib/cloudflare/bucket.js.map +0 -1
- package/lib/cloudflare/durable-object-namespace.d.ts.map +0 -1
- package/lib/cloudflare/durable-object-namespace.js.map +0 -1
- package/lib/cloudflare/generate-asset-manifest.d.ts.map +0 -1
- package/lib/cloudflare/generate-asset-manifest.js.map +0 -1
- package/lib/cloudflare/index.d.ts.map +0 -1
- package/lib/cloudflare/index.js.map +0 -1
- package/lib/cloudflare/kv-namespace.d.ts.map +0 -1
- package/lib/cloudflare/kv-namespace.js.map +0 -1
- package/lib/cloudflare/state.d.ts.map +0 -1
- package/lib/cloudflare/state.js.map +0 -1
- package/lib/cloudflare/static-site-router.d.ts.map +0 -1
- package/lib/cloudflare/static-site-router.js.map +0 -1
- package/lib/cloudflare/static-site.d.ts.map +0 -1
- package/lib/cloudflare/static-site.js.map +0 -1
- package/lib/cloudflare/types.d.ts.map +0 -1
- package/lib/cloudflare/types.js.map +0 -1
- package/lib/cloudflare/upload-asset-manifest.d.ts.map +0 -1
- package/lib/cloudflare/upload-asset-manifest.js.map +0 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +0 -1
- package/lib/cloudflare/worker-metadata.js.map +0 -1
- package/lib/cloudflare/worker-migration.d.ts.map +0 -1
- package/lib/cloudflare/worker-migration.js.map +0 -1
- package/lib/cloudflare/worker.d.ts.map +0 -1
- package/lib/cloudflare/worker.js.map +0 -1
- package/lib/destroy.d.ts.map +0 -1
- package/lib/destroy.js.map +0 -1
- package/lib/encrypt.d.ts.map +0 -1
- package/lib/encrypt.js.map +0 -1
- package/lib/error.d.ts.map +0 -1
- package/lib/error.js.map +0 -1
- package/lib/esbuild.d.ts.map +0 -1
- package/lib/esbuild.js.map +0 -1
- package/lib/fs.d.ts +0 -12
- package/lib/fs.d.ts.map +0 -1
- package/lib/fs.js +0 -41
- package/lib/fs.js.map +0 -1
- package/lib/github/client.d.ts.map +0 -1
- package/lib/github/client.js.map +0 -1
- package/lib/github/index.d.ts.map +0 -1
- package/lib/github/index.js.map +0 -1
- package/lib/github/secret.d.ts.map +0 -1
- package/lib/github/secret.js.map +0 -1
- package/lib/global.d.ts +0 -16
- package/lib/global.d.ts.map +0 -1
- package/lib/global.js +0 -42
- package/lib/global.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/input.d.ts +0 -7
- package/lib/input.d.ts.map +0 -1
- package/lib/input.js +0 -2
- package/lib/input.js.map +0 -1
- package/lib/main.d.ts +0 -3
- package/lib/main.d.ts.map +0 -1
- package/lib/main.js +0 -32
- package/lib/main.js.map +0 -1
- package/lib/output.d.ts +0 -25
- package/lib/output.d.ts.map +0 -1
- package/lib/output.js +0 -23
- package/lib/output.js.map +0 -1
- package/lib/print.d.ts +0 -7
- package/lib/print.d.ts.map +0 -1
- package/lib/print.js +0 -10
- package/lib/print.js.map +0 -1
- package/lib/resource.d.ts.map +0 -1
- package/lib/resource.js.map +0 -1
- package/lib/scope.d.ts.map +0 -1
- package/lib/scope.js.map +0 -1
- package/lib/secret.d.ts.map +0 -1
- package/lib/secret.js.map +0 -1
- package/lib/serde.d.ts +0 -3
- package/lib/serde.d.ts.map +0 -1
- package/lib/serde.js.map +0 -1
- package/lib/slug.d.ts +0 -2
- package/lib/slug.d.ts.map +0 -1
- package/lib/slug.js +0 -4
- package/lib/slug.js.map +0 -1
- package/lib/state.d.ts.map +0 -1
- package/lib/state.js.map +0 -1
- package/lib/stripe/index.d.ts.map +0 -1
- package/lib/stripe/index.js.map +0 -1
- package/lib/stripe/price.d.ts.map +0 -1
- package/lib/stripe/price.js.map +0 -1
- package/lib/stripe/product.d.ts.map +0 -1
- package/lib/stripe/product.js.map +0 -1
- package/lib/stripe/webhook.d.ts.map +0 -1
- package/lib/stripe/webhook.js.map +0 -1
- package/lib/utils/content-type.d.ts.map +0 -1
- package/lib/utils/content-type.js.map +0 -1
- package/lib/utils/retry.d.ts.map +0 -1
- package/lib/utils/retry.js.map +0 -1
- package/src/$.ts +0 -69
- package/src/alchemize.ts +0 -195
- package/src/fs.ts +0 -47
- package/src/global.ts +0 -63
- package/src/input.ts +0 -19
- package/src/main.ts +0 -34
- package/src/output.ts +0 -75
- package/src/print.ts +0 -18
- package/src/serde.ts +0 -46
- package/src/slug.ts +0 -3
- /package/src/{utils → util}/content-type.ts +0 -0
- /package/src/{encrypt.ts → util/encrypt.ts} +0 -0
- /package/src/{error.ts → util/ignore.ts} +0 -0
- /package/src/{utils → util}/retry.ts +0 -0
|
@@ -9,13 +9,13 @@ const TRUST_POLICY_SID = "GitHubOIDCTrust";
|
|
|
9
9
|
/**
|
|
10
10
|
* Resource for configuring AWS OIDC provider for GitHub Actions
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export const OIDCProvider = Resource("aws::OIDCProvider", async function (id, props) {
|
|
13
13
|
// Initialize AWS SDK client
|
|
14
14
|
const client = new IAMClient({
|
|
15
15
|
region: props.region,
|
|
16
16
|
});
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
17
|
+
if (this.phase === "delete") {
|
|
18
|
+
if (this.output?.providerArn) {
|
|
19
19
|
try {
|
|
20
20
|
// First, remove our trust policy statement from the role
|
|
21
21
|
const getRole = await client.send(new GetRoleCommand({
|
|
@@ -32,12 +32,12 @@ export class OIDCProvider extends Resource("aws::OIDCProvider", async (ctx, prop
|
|
|
32
32
|
}
|
|
33
33
|
// Then delete the OIDC provider if we're the last user
|
|
34
34
|
const provider = await client.send(new GetOpenIDConnectProviderCommand({
|
|
35
|
-
OpenIDConnectProviderArn:
|
|
35
|
+
OpenIDConnectProviderArn: this.output.providerArn,
|
|
36
36
|
}));
|
|
37
37
|
// Only delete the provider if it exists and has no other tags
|
|
38
38
|
if (provider && (!provider.Tags || provider.Tags.length === 0)) {
|
|
39
39
|
await client.send(new DeleteOpenIDConnectProviderCommand({
|
|
40
|
-
OpenIDConnectProviderArn:
|
|
40
|
+
OpenIDConnectProviderArn: this.output.providerArn,
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -46,7 +46,7 @@ export class OIDCProvider extends Resource("aws::OIDCProvider", async (ctx, prop
|
|
|
46
46
|
console.error("Error during cleanup:", error);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
return;
|
|
49
|
+
return this.destroy();
|
|
50
50
|
}
|
|
51
51
|
try {
|
|
52
52
|
const url = "https://token.actions.githubusercontent.com";
|
|
@@ -125,16 +125,14 @@ export class OIDCProvider extends Resource("aws::OIDCProvider", async (ctx, prop
|
|
|
125
125
|
RoleName: props.roleArn.split("/").pop(),
|
|
126
126
|
PolicyDocument: JSON.stringify(policy),
|
|
127
127
|
}));
|
|
128
|
-
return {
|
|
128
|
+
return this({
|
|
129
129
|
...props,
|
|
130
130
|
providerArn,
|
|
131
131
|
createdAt: Date.now(),
|
|
132
|
-
};
|
|
132
|
+
});
|
|
133
133
|
}
|
|
134
134
|
catch (error) {
|
|
135
135
|
console.error("Error configuring OIDC provider:", error);
|
|
136
136
|
throw error;
|
|
137
137
|
}
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=oidc-provider.js.map
|
|
138
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from "../context";
|
|
2
|
+
import { Resource } from "../resource";
|
|
3
|
+
export interface PolicyAttachmentProps {
|
|
4
|
+
policyArn: string;
|
|
5
|
+
roleName: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PolicyAttachment extends Resource<"iam::PolicyAttachment">, PolicyAttachmentProps {
|
|
8
|
+
}
|
|
9
|
+
export declare const PolicyAttachment: ((this: Context<PolicyAttachment>, id: string, props: PolicyAttachmentProps) => Promise<PolicyAttachment>) | (((this: any, id: string, props: PolicyAttachmentProps) => never) & (new (_: never) => never));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AttachRolePolicyCommand, DetachRolePolicyCommand, IAMClient, NoSuchEntityException, } from "@aws-sdk/client-iam";
|
|
2
|
+
import { Resource } from "../resource";
|
|
3
|
+
import { ignore } from "../util/ignore";
|
|
4
|
+
export const PolicyAttachment = Resource("iam::PolicyAttachment", async function (id, props) {
|
|
5
|
+
const client = new IAMClient({});
|
|
6
|
+
if (this.phase === "delete") {
|
|
7
|
+
await ignore(NoSuchEntityException.name, () => client.send(new DetachRolePolicyCommand({
|
|
8
|
+
PolicyArn: props.policyArn,
|
|
9
|
+
RoleName: props.roleName,
|
|
10
|
+
})));
|
|
11
|
+
return this.destroy();
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
await client.send(new AttachRolePolicyCommand({
|
|
15
|
+
PolicyArn: props.policyArn,
|
|
16
|
+
RoleName: props.roleName,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
return this(props);
|
|
20
|
+
});
|
package/lib/aws/policy.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Context } from "../context";
|
|
2
|
+
import { Resource } from "../resource";
|
|
1
3
|
export type Effect = "Allow" | "Deny";
|
|
2
4
|
export interface PolicyStatement {
|
|
3
5
|
Sid?: string;
|
|
@@ -21,8 +23,7 @@ export interface PolicyProps {
|
|
|
21
23
|
path?: string;
|
|
22
24
|
tags?: Record<string, string>;
|
|
23
25
|
}
|
|
24
|
-
export interface
|
|
25
|
-
id: string;
|
|
26
|
+
export interface Policy extends Resource<"iam::Policy">, PolicyProps {
|
|
26
27
|
arn: string;
|
|
27
28
|
defaultVersionId: string;
|
|
28
29
|
attachmentCount: number;
|
|
@@ -30,17 +31,4 @@ export interface PolicyOutput extends PolicyProps {
|
|
|
30
31
|
updateDate: Date;
|
|
31
32
|
isAttachable: boolean;
|
|
32
33
|
}
|
|
33
|
-
declare const
|
|
34
|
-
export declare class Policy extends Policy_base {
|
|
35
|
-
}
|
|
36
|
-
export interface PolicyAttachmentProps {
|
|
37
|
-
policyArn: string;
|
|
38
|
-
roleName: string;
|
|
39
|
-
}
|
|
40
|
-
export interface PolicyAttachmentOutput extends PolicyAttachmentProps {
|
|
41
|
-
}
|
|
42
|
-
declare const PolicyAttachment_base: import("../resource").Provider<"iam::PolicyAttachment", [props: PolicyAttachmentProps], PolicyAttachmentProps>;
|
|
43
|
-
export declare class PolicyAttachment extends PolicyAttachment_base {
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
46
|
-
//# sourceMappingURL=policy.d.ts.map
|
|
34
|
+
export declare const Policy: ((this: Context<Policy>, id: string, props: PolicyProps) => Promise<Policy>) | (((this: any, id: string, props: PolicyProps) => never) & (new (_: never) => never));
|
package/lib/aws/policy.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ignore } from "../error";
|
|
1
|
+
import { CreatePolicyCommand, CreatePolicyVersionCommand, DeletePolicyCommand, DeletePolicyVersionCommand, GetPolicyCommand, GetPolicyVersionCommand, IAMClient, ListPolicyVersionsCommand, NoSuchEntityException, } from "@aws-sdk/client-iam";
|
|
3
2
|
import { Resource } from "../resource";
|
|
4
|
-
export
|
|
3
|
+
export const Policy = Resource("iam::Policy", async function (id, props) {
|
|
5
4
|
const client = new IAMClient({});
|
|
6
5
|
const policyArn = `arn:aws:iam::${process.env.AWS_ACCOUNT_ID}:policy${props.path || "/"}${props.policyName}`;
|
|
7
|
-
if (
|
|
6
|
+
if (this.phase === "delete") {
|
|
8
7
|
try {
|
|
9
8
|
// List and delete all non-default versions first
|
|
10
9
|
const versions = await client.send(new ListPolicyVersionsCommand({
|
|
@@ -28,16 +27,7 @@ export class Policy extends Resource("iam::Policy", async (ctx, props) => {
|
|
|
28
27
|
throw error;
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
return
|
|
32
|
-
...props,
|
|
33
|
-
id: props.policyName,
|
|
34
|
-
arn: policyArn,
|
|
35
|
-
defaultVersionId: "v1",
|
|
36
|
-
attachmentCount: 0,
|
|
37
|
-
createDate: new Date(),
|
|
38
|
-
updateDate: new Date(),
|
|
39
|
-
isAttachable: true,
|
|
40
|
-
};
|
|
30
|
+
return this.destroy();
|
|
41
31
|
}
|
|
42
32
|
else {
|
|
43
33
|
try {
|
|
@@ -77,16 +67,15 @@ export class Policy extends Resource("iam::Policy", async (ctx, props) => {
|
|
|
77
67
|
const policy = await client.send(new GetPolicyCommand({
|
|
78
68
|
PolicyArn: policyArn,
|
|
79
69
|
}));
|
|
80
|
-
return {
|
|
70
|
+
return this({
|
|
81
71
|
...props,
|
|
82
|
-
id: props.policyName,
|
|
83
72
|
arn: policy.Policy.Arn,
|
|
84
73
|
defaultVersionId: policy.Policy.DefaultVersionId,
|
|
85
74
|
attachmentCount: policy.Policy.AttachmentCount,
|
|
86
75
|
createDate: policy.Policy.CreateDate,
|
|
87
76
|
updateDate: policy.Policy.UpdateDate,
|
|
88
77
|
isAttachable: policy.Policy.IsAttachable,
|
|
89
|
-
};
|
|
78
|
+
});
|
|
90
79
|
}
|
|
91
80
|
catch (error) {
|
|
92
81
|
if (error.name === "NoSuchEntity") {
|
|
@@ -103,37 +92,17 @@ export class Policy extends Resource("iam::Policy", async (ctx, props) => {
|
|
|
103
92
|
}))
|
|
104
93
|
: undefined,
|
|
105
94
|
}));
|
|
106
|
-
return {
|
|
95
|
+
return this({
|
|
107
96
|
...props,
|
|
108
|
-
id: props.policyName,
|
|
109
97
|
arn: newPolicy.Policy.Arn,
|
|
110
98
|
defaultVersionId: newPolicy.Policy.DefaultVersionId,
|
|
111
99
|
attachmentCount: newPolicy.Policy.AttachmentCount,
|
|
112
100
|
createDate: newPolicy.Policy.CreateDate,
|
|
113
101
|
updateDate: newPolicy.Policy.UpdateDate,
|
|
114
102
|
isAttachable: newPolicy.Policy.IsAttachable,
|
|
115
|
-
};
|
|
103
|
+
});
|
|
116
104
|
}
|
|
117
105
|
throw error;
|
|
118
106
|
}
|
|
119
107
|
}
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
export class PolicyAttachment extends Resource("iam::PolicyAttachment", async (ctx, props) => {
|
|
123
|
-
const client = new IAMClient({});
|
|
124
|
-
if (ctx.event === "delete") {
|
|
125
|
-
await ignore(NoSuchEntityException.name, () => client.send(new DetachRolePolicyCommand({
|
|
126
|
-
PolicyArn: props.policyArn,
|
|
127
|
-
RoleName: props.roleName,
|
|
128
|
-
})));
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
await client.send(new AttachRolePolicyCommand({
|
|
132
|
-
PolicyArn: props.policyArn,
|
|
133
|
-
RoleName: props.roleName,
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
return props;
|
|
137
|
-
}) {
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=policy.js.map
|
|
108
|
+
});
|
package/lib/aws/queue.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Context } from "../context";
|
|
2
|
+
import { Resource } from "../resource";
|
|
1
3
|
export interface QueueProps {
|
|
2
4
|
/**
|
|
3
5
|
* Name of the queue
|
|
@@ -23,40 +25,8 @@ export interface QueueProps {
|
|
|
23
25
|
fifoThroughputLimit?: "perQueue" | "perMessageGroupId";
|
|
24
26
|
tags?: Record<string, string>;
|
|
25
27
|
}
|
|
26
|
-
export interface
|
|
27
|
-
id: string;
|
|
28
|
+
export interface Queue extends Resource<"sqs::Queue">, QueueProps {
|
|
28
29
|
arn: string;
|
|
29
30
|
url: string;
|
|
30
31
|
}
|
|
31
|
-
declare const
|
|
32
|
-
id: string;
|
|
33
|
-
arn: string;
|
|
34
|
-
url: string;
|
|
35
|
-
/**
|
|
36
|
-
* Name of the queue
|
|
37
|
-
* For FIFO queues, the name must end with the .fifo suffix
|
|
38
|
-
*/
|
|
39
|
-
queueName: string;
|
|
40
|
-
/**
|
|
41
|
-
* Whether this is a FIFO queue.
|
|
42
|
-
* If true, the queueName must end with .fifo suffix
|
|
43
|
-
*/
|
|
44
|
-
fifo?: boolean;
|
|
45
|
-
visibilityTimeout?: number;
|
|
46
|
-
messageRetentionPeriod?: number;
|
|
47
|
-
maximumMessageSize?: number;
|
|
48
|
-
delaySeconds?: number;
|
|
49
|
-
receiveMessageWaitTimeSeconds?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Enables content-based deduplication for FIFO queues.
|
|
52
|
-
* Only applicable when fifo is true.
|
|
53
|
-
*/
|
|
54
|
-
contentBasedDeduplication?: boolean;
|
|
55
|
-
deduplicationScope?: "messageGroup" | "queue";
|
|
56
|
-
fifoThroughputLimit?: "perQueue" | "perMessageGroupId";
|
|
57
|
-
tags?: Record<string, string>;
|
|
58
|
-
}>;
|
|
59
|
-
export declare class Queue extends Queue_base {
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=queue.d.ts.map
|
|
32
|
+
export declare const Queue: ((this: Context<Queue>, id: string, props: QueueProps) => Promise<Queue>) | (((this: any, id: string, props: QueueProps) => never) & (new (_: never) => never));
|
package/lib/aws/queue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreateQueueCommand, DeleteQueueCommand, GetQueueAttributesCommand, GetQueueUrlCommand, SQSClient, } from "@aws-sdk/client-sqs";
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
|
-
export
|
|
3
|
+
export const Queue = Resource("sqs::Queue", async function (id, props) {
|
|
4
4
|
const client = new SQSClient({});
|
|
5
5
|
// Don't automatically add .fifo suffix - user must include it in queueName
|
|
6
6
|
const queueName = props.queueName;
|
|
@@ -8,7 +8,7 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
8
8
|
if (props.fifo && !queueName.endsWith(".fifo")) {
|
|
9
9
|
throw new Error("FIFO queue names must end with .fifo suffix");
|
|
10
10
|
}
|
|
11
|
-
if (
|
|
11
|
+
if (this.phase === "delete") {
|
|
12
12
|
try {
|
|
13
13
|
// Get queue URL first
|
|
14
14
|
const urlResponse = await client.send(new GetQueueUrlCommand({
|
|
@@ -43,12 +43,7 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
43
43
|
throw error;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
47
|
-
...props,
|
|
48
|
-
id: props.queueName,
|
|
49
|
-
arn: `arn:aws:sqs:${client.config.region}:${process.env.AWS_ACCOUNT_ID}:${queueName}`,
|
|
50
|
-
url: "",
|
|
51
|
-
};
|
|
46
|
+
return this.destroy();
|
|
52
47
|
}
|
|
53
48
|
else {
|
|
54
49
|
// Create queue with attributes
|
|
@@ -99,12 +94,11 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
99
94
|
QueueUrl: createResponse.QueueUrl,
|
|
100
95
|
AttributeNames: ["QueueArn"],
|
|
101
96
|
}));
|
|
102
|
-
return {
|
|
97
|
+
return this({
|
|
103
98
|
...props,
|
|
104
|
-
id: props.queueName,
|
|
105
99
|
arn: attributesResponse.Attributes.QueueArn,
|
|
106
100
|
url: createResponse.QueueUrl,
|
|
107
|
-
};
|
|
101
|
+
});
|
|
108
102
|
}
|
|
109
103
|
catch (error) {
|
|
110
104
|
if (error.name === "QueueAlreadyExists") {
|
|
@@ -117,12 +111,11 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
117
111
|
QueueUrl: urlResponse.QueueUrl,
|
|
118
112
|
AttributeNames: ["QueueArn"],
|
|
119
113
|
}));
|
|
120
|
-
return {
|
|
114
|
+
return this({
|
|
121
115
|
...props,
|
|
122
|
-
id: props.queueName,
|
|
123
116
|
arn: attributesResponse.Attributes.QueueArn,
|
|
124
117
|
url: urlResponse.QueueUrl,
|
|
125
|
-
};
|
|
118
|
+
});
|
|
126
119
|
}
|
|
127
120
|
else if (error.name === "QueueDeletedRecently") {
|
|
128
121
|
// Queue was recently deleted, wait and retry
|
|
@@ -143,12 +136,11 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
143
136
|
QueueUrl: createResponse.QueueUrl,
|
|
144
137
|
AttributeNames: ["QueueArn"],
|
|
145
138
|
}));
|
|
146
|
-
return {
|
|
139
|
+
return this({
|
|
147
140
|
...props,
|
|
148
|
-
id: props.queueName,
|
|
149
141
|
arn: attributesResponse.Attributes.QueueArn,
|
|
150
142
|
url: createResponse.QueueUrl,
|
|
151
|
-
};
|
|
143
|
+
});
|
|
152
144
|
}
|
|
153
145
|
catch (retryError) {
|
|
154
146
|
if (retryError.name !== "QueueDeletedRecently" ||
|
|
@@ -162,6 +154,4 @@ export class Queue extends Resource("sqs::Queue", async (ctx, props) => {
|
|
|
162
154
|
throw error;
|
|
163
155
|
}
|
|
164
156
|
}
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=queue.js.map
|
|
157
|
+
});
|
package/lib/aws/role.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Context } from "../context";
|
|
2
|
+
import { Resource } from "../resource";
|
|
1
3
|
import type { PolicyDocument } from "./policy";
|
|
2
4
|
export interface RoleProps {
|
|
3
5
|
roleName: string;
|
|
@@ -13,15 +15,10 @@ export interface RoleProps {
|
|
|
13
15
|
managedPolicyArns?: string[];
|
|
14
16
|
tags?: Record<string, string>;
|
|
15
17
|
}
|
|
16
|
-
export interface
|
|
17
|
-
id: string;
|
|
18
|
+
export interface Role extends Resource<"iam::Role">, RoleProps {
|
|
18
19
|
arn: string;
|
|
19
20
|
uniqueId: string;
|
|
20
21
|
roleId: string;
|
|
21
22
|
createDate: Date;
|
|
22
23
|
}
|
|
23
|
-
declare const
|
|
24
|
-
export declare class Role extends Role_base {
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=role.d.ts.map
|
|
24
|
+
export declare const Role: ((this: Context<Role>, id: string, props: RoleProps) => Promise<Role>) | (((this: any, id: string, props: RoleProps) => never) & (new (_: never) => never));
|
package/lib/aws/role.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AttachRolePolicyCommand, CreateRoleCommand, DeleteRoleCommand, DeleteRolePolicyCommand, DetachRolePolicyCommand, EntityAlreadyExistsException, GetRoleCommand, IAMClient, ListAttachedRolePoliciesCommand, NoSuchEntityException, PutRolePolicyCommand, TagRoleCommand, UpdateAssumeRolePolicyCommand, UpdateRoleCommand, } from "@aws-sdk/client-iam";
|
|
2
|
-
import { ignore } from "../error";
|
|
3
2
|
import { Resource } from "../resource";
|
|
4
|
-
|
|
3
|
+
import { ignore } from "../util/ignore";
|
|
4
|
+
export const Role = Resource("iam::Role", async function (id, props) {
|
|
5
5
|
const client = new IAMClient({});
|
|
6
|
-
if (
|
|
6
|
+
if (this.phase === "delete") {
|
|
7
7
|
// Delete any inline policies first
|
|
8
8
|
if (props.policies) {
|
|
9
9
|
for (const policy of props.policies) {
|
|
@@ -36,19 +36,12 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
36
36
|
await ignore(NoSuchEntityException.name, () => client.send(new DeleteRoleCommand({
|
|
37
37
|
RoleName: props.roleName,
|
|
38
38
|
})));
|
|
39
|
-
return
|
|
40
|
-
...props,
|
|
41
|
-
id: props.roleName,
|
|
42
|
-
arn: `arn:aws:iam::${process.env.AWS_ACCOUNT_ID}:role/${props.roleName}`,
|
|
43
|
-
uniqueId: "",
|
|
44
|
-
roleId: "",
|
|
45
|
-
createDate: new Date(),
|
|
46
|
-
};
|
|
39
|
+
return this.destroy();
|
|
47
40
|
}
|
|
48
41
|
const assumeRolePolicyDocument = JSON.stringify(props.assumeRolePolicy);
|
|
49
42
|
let role;
|
|
50
43
|
try {
|
|
51
|
-
if (
|
|
44
|
+
if (this.phase === "create") {
|
|
52
45
|
// Try to create the role
|
|
53
46
|
await client.send(new CreateRoleCommand({
|
|
54
47
|
RoleName: props.roleName,
|
|
@@ -64,11 +57,11 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
64
57
|
})),
|
|
65
58
|
{
|
|
66
59
|
Key: "alchemy_stage",
|
|
67
|
-
Value:
|
|
60
|
+
Value: this.stage,
|
|
68
61
|
},
|
|
69
62
|
{
|
|
70
63
|
Key: "alchemy_resource",
|
|
71
|
-
Value:
|
|
64
|
+
Value: this.id,
|
|
72
65
|
},
|
|
73
66
|
],
|
|
74
67
|
}));
|
|
@@ -76,7 +69,7 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
76
69
|
}
|
|
77
70
|
catch (error) {
|
|
78
71
|
if (error instanceof EntityAlreadyExistsException &&
|
|
79
|
-
|
|
72
|
+
this.phase === "create") {
|
|
80
73
|
// Check if we were the ones who created it
|
|
81
74
|
const existingRole = await client.send(new GetRoleCommand({
|
|
82
75
|
RoleName: props.roleName,
|
|
@@ -85,8 +78,8 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
85
78
|
acc[tag.Key] = tag.Value;
|
|
86
79
|
return acc;
|
|
87
80
|
}, {}) || {};
|
|
88
|
-
if (roleTags.alchemy_stage !==
|
|
89
|
-
roleTags.alchemy_resource !==
|
|
81
|
+
if (roleTags.alchemy_stage !== this.stage ||
|
|
82
|
+
roleTags.alchemy_resource !== this.id) {
|
|
90
83
|
throw error;
|
|
91
84
|
}
|
|
92
85
|
}
|
|
@@ -117,8 +110,8 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
117
110
|
// Update tags
|
|
118
111
|
const newTags = {
|
|
119
112
|
...props.tags,
|
|
120
|
-
alchemy_stage:
|
|
121
|
-
alchemy_resource:
|
|
113
|
+
alchemy_stage: this.stage,
|
|
114
|
+
alchemy_resource: this.id,
|
|
122
115
|
};
|
|
123
116
|
const tags = Object.entries(newTags).map(([Key, Value]) => ({
|
|
124
117
|
Key,
|
|
@@ -129,7 +122,7 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
129
122
|
Tags: tags,
|
|
130
123
|
}));
|
|
131
124
|
// Handle policy changes
|
|
132
|
-
const previousPolicies =
|
|
125
|
+
const previousPolicies = this.phase === "update" ? this.output.policies || [] : [];
|
|
133
126
|
const currentPolicies = props.policies || [];
|
|
134
127
|
// Delete policies that were removed
|
|
135
128
|
for (const oldPolicy of previousPolicies) {
|
|
@@ -184,14 +177,12 @@ export class Role extends Resource("iam::Role", async (ctx, props) => {
|
|
|
184
177
|
if (!role?.Role) {
|
|
185
178
|
throw new Error(`Failed to create or update role ${props.roleName}`);
|
|
186
179
|
}
|
|
187
|
-
return {
|
|
180
|
+
return this({
|
|
188
181
|
...props,
|
|
189
|
-
id: props.roleName,
|
|
190
182
|
arn: role.Role.Arn,
|
|
191
183
|
uniqueId: role.Role.RoleId,
|
|
192
184
|
roleId: role.Role.RoleId,
|
|
185
|
+
roleName: role.Role.RoleName ?? props.roleName,
|
|
193
186
|
createDate: role.Role.CreateDate,
|
|
194
|
-
};
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=role.js.map
|
|
187
|
+
});
|
|
188
|
+
});
|
package/lib/aws/ses.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type DeliveryOptions, type ReputationOptions, type SendingOptions, type SuppressionOptions, type TrackingOptions } from "@aws-sdk/client-sesv2";
|
|
2
|
+
import type { Context } from "../context";
|
|
3
|
+
import { Resource } from "../resource";
|
|
2
4
|
/**
|
|
3
5
|
* Properties for configuring AWS SES resources
|
|
4
6
|
*/
|
|
@@ -43,11 +45,7 @@ export interface SESProps {
|
|
|
43
45
|
/**
|
|
44
46
|
* Output returned after SES resource creation/update
|
|
45
47
|
*/
|
|
46
|
-
export interface
|
|
47
|
-
/**
|
|
48
|
-
* Resource ID
|
|
49
|
-
*/
|
|
50
|
-
id: string;
|
|
48
|
+
export interface SES extends Resource<"aws::SES">, SESProps {
|
|
51
49
|
/**
|
|
52
50
|
* ARN of the configuration set if created
|
|
53
51
|
*/
|
|
@@ -65,11 +63,7 @@ export interface SESOutput extends SESProps {
|
|
|
65
63
|
*/
|
|
66
64
|
emailIdentityArn?: string;
|
|
67
65
|
}
|
|
68
|
-
declare const SES_base: import("../resource").Provider<"aws::SES", [props: SESProps], SESOutput>;
|
|
69
66
|
/**
|
|
70
67
|
* AWS SES resource for creating and configuring Simple Email Service
|
|
71
68
|
*/
|
|
72
|
-
export declare
|
|
73
|
-
}
|
|
74
|
-
export {};
|
|
75
|
-
//# sourceMappingURL=ses.d.ts.map
|
|
69
|
+
export declare const SES: ((this: Context<SES>, id: string, props: SESProps) => Promise<SES>) | (((this: any, id: string, props: SESProps) => never) & (new (_: never) => never));
|