@composurecdk/xray 0.10.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason Duffett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @composurecdk/xray
2
+
3
+ AWS X-Ray for [ComposureCDK](../../README.md). It enables [CloudWatch Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html), which sends X-Ray spans to CloudWatch Logs so they can be searched and analysed. Amazon Bedrock AgentCore online evaluation needs it.
4
+
5
+ ```ts
6
+ import { createTransactionSearchBuilder } from "@composurecdk/xray";
7
+
8
+ createTransactionSearchBuilder().build(stack, "TransactionSearch");
9
+ ```
10
+
11
+ Transaction Search is one setting for the whole account and Region, so build it in exactly one stack:
12
+
13
+ - If it is already on, the deploy fails with `AlreadyExists` and rolls back. If it was enabled by hand, turn it off first with `aws xray update-trace-segment-destination --destination XRay`.
14
+ - Deploying waits several minutes for it to become active.
15
+ - Destroying the stack turns it off, including for other stacks that rely on it.
16
+
17
+ The builder creates:
18
+
19
+ - the `AWS::XRay::TransactionSearchConfig`, indexing 1% of spans as trace summaries by default. Raise it with `.indexingPercentage(...)`.
20
+ - a CloudWatch Logs resource policy that lets X-Ray write to `aws/spans` and `/aws/application-signals/data`. The policy is conditioned on this account's `aws:SourceAccount` and `aws:SourceArn`.
21
+
22
+ Spans are billed at CloudWatch Logs ingestion rates. See [CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/).
@@ -0,0 +1,7 @@
1
+ import type { CfnTransactionSearchConfigProps } from "aws-cdk-lib/aws-xray";
2
+ /**
3
+ * Defaults applied by {@link createTransactionSearchBuilder}. Each can be
4
+ * overridden through the builder.
5
+ */
6
+ export declare const TRANSACTION_SEARCH_DEFAULTS: Partial<CfnTransactionSearchConfigProps>;
7
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,+BAA+B,CAOhF,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRANSACTION_SEARCH_DEFAULTS = void 0;
4
+ /**
5
+ * Defaults applied by {@link createTransactionSearchBuilder}. Each can be
6
+ * overridden through the builder.
7
+ */
8
+ exports.TRANSACTION_SEARCH_DEFAULTS = {
9
+ /**
10
+ * Index 1% of spans as trace summaries: free, and AWS's default. Every span
11
+ * is still ingested and searchable.
12
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
13
+ */
14
+ indexingPercentage: 1,
15
+ };
16
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,2BAA2B,GAA6C;IACnF;;;;OAIG;IACH,kBAAkB,EAAE,CAAC;CACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { TRANSACTION_SEARCH_DEFAULTS } from "./defaults.js";
2
+ export { createTransactionSearchBuilder, type ITransactionSearchBuilder, type TransactionSearchBuilderProps, type TransactionSearchBuilderResult, } from "./transaction-search-builder.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,8BAA8B,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransactionSearchBuilder = exports.TRANSACTION_SEARCH_DEFAULTS = void 0;
4
+ var defaults_js_1 = require("./defaults.js");
5
+ Object.defineProperty(exports, "TRANSACTION_SEARCH_DEFAULTS", { enumerable: true, get: function () { return defaults_js_1.TRANSACTION_SEARCH_DEFAULTS; } });
6
+ var transaction_search_builder_js_1 = require("./transaction-search-builder.js");
7
+ Object.defineProperty(exports, "createTransactionSearchBuilder", { enumerable: true, get: function () { return transaction_search_builder_js_1.createTransactionSearchBuilder; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4D;AAAnD,0HAAA,2BAA2B,OAAA;AACpC,iFAKyC;AAJvC,+IAAA,8BAA8B,OAAA"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,36 @@
1
+ import { ResourcePolicy } from "aws-cdk-lib/aws-logs";
2
+ import { CfnTransactionSearchConfig, type CfnTransactionSearchConfigProps } from "aws-cdk-lib/aws-xray";
3
+ import type { IConstruct } from "constructs";
4
+ import { type IBuilder, type Lifecycle } from "@composurecdk/core";
5
+ /** Configuration properties for {@link createTransactionSearchBuilder}. */
6
+ export type TransactionSearchBuilderProps = CfnTransactionSearchConfigProps;
7
+ /** The build output of an {@link ITransactionSearchBuilder}. */
8
+ export interface TransactionSearchBuilderResult {
9
+ transactionSearch: CfnTransactionSearchConfig;
10
+ /** Lets X-Ray write spans to CloudWatch Logs. */
11
+ resourcePolicy: ResourcePolicy;
12
+ }
13
+ /**
14
+ * A fluent builder that enables CloudWatch Transaction Search.
15
+ *
16
+ * @see {@link createTransactionSearchBuilder}
17
+ */
18
+ export type ITransactionSearchBuilder = IBuilder<TransactionSearchBuilderProps, TransactionSearchBuilder>;
19
+ declare class TransactionSearchBuilder implements Lifecycle<TransactionSearchBuilderResult> {
20
+ props: Partial<TransactionSearchBuilderProps>;
21
+ build(scope: IConstruct, id: string): TransactionSearchBuilderResult;
22
+ }
23
+ /**
24
+ * Creates a builder that enables CloudWatch Transaction Search for the account
25
+ * and Region. Build it in exactly one stack.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * createTransactionSearchBuilder().build(stack, "TransactionSearch");
30
+ * ```
31
+ *
32
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
33
+ */
34
+ export declare function createTransactionSearchBuilder(): ITransactionSearchBuilder;
35
+ export {};
36
+ //# sourceMappingURL=transaction-search-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-search-builder.d.ts","sourceRoot":"","sources":["../../src/transaction-search-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG5E,2EAA2E;AAC3E,MAAM,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAE5E,gEAAgE;AAChE,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,EAAE,0BAA0B,CAAC;IAC9C,iDAAiD;IACjD,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;GAIG;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,6BAA6B,EAC7B,wBAAwB,CACzB,CAAC;AAKF,cAAM,wBAAyB,YAAW,SAAS,CAAC,8BAA8B,CAAC;IACjF,KAAK,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAM;IAEnD,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,8BAA8B;CAoCrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,IAAI,yBAAyB,CAG1E"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTransactionSearchBuilder = createTransactionSearchBuilder;
4
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
5
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
6
+ const aws_logs_1 = require("aws-cdk-lib/aws-logs");
7
+ const aws_xray_1 = require("aws-cdk-lib/aws-xray");
8
+ const core_1 = require("@composurecdk/core");
9
+ const defaults_js_1 = require("./defaults.js");
10
+ /** The log groups Transaction Search writes to. */
11
+ const SPAN_LOG_GROUPS = ["aws/spans", "/aws/application-signals/data"];
12
+ class TransactionSearchBuilder {
13
+ props = {};
14
+ build(scope, id) {
15
+ const stack = aws_cdk_lib_1.Stack.of(scope);
16
+ const resourcePolicy = new aws_logs_1.ResourcePolicy(scope, `${id}LogsPolicy`, {
17
+ policyStatements: [
18
+ new aws_iam_1.PolicyStatement({
19
+ sid: "TransactionSearchXRayAccess",
20
+ principals: [new aws_iam_1.ServicePrincipal("xray.amazonaws.com")],
21
+ actions: ["logs:PutLogEvents"],
22
+ resources: SPAN_LOG_GROUPS.map((name) => stack.formatArn({
23
+ service: "logs",
24
+ resource: "log-group",
25
+ resourceName: `${name}:*`,
26
+ arnFormat: aws_cdk_lib_1.ArnFormat.COLON_RESOURCE_NAME,
27
+ })),
28
+ conditions: {
29
+ ArnLike: {
30
+ "aws:SourceArn": stack.formatArn({
31
+ service: "xray",
32
+ resource: "*",
33
+ arnFormat: aws_cdk_lib_1.ArnFormat.NO_RESOURCE_NAME,
34
+ }),
35
+ },
36
+ StringEquals: { "aws:SourceAccount": stack.account },
37
+ },
38
+ }),
39
+ ],
40
+ });
41
+ const transactionSearch = new aws_xray_1.CfnTransactionSearchConfig(scope, id, {
42
+ ...defaults_js_1.TRANSACTION_SEARCH_DEFAULTS,
43
+ ...this.props,
44
+ });
45
+ transactionSearch.node.addDependency(resourcePolicy);
46
+ return { transactionSearch, resourcePolicy };
47
+ }
48
+ }
49
+ /**
50
+ * Creates a builder that enables CloudWatch Transaction Search for the account
51
+ * and Region. Build it in exactly one stack.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * createTransactionSearchBuilder().build(stack, "TransactionSearch");
56
+ * ```
57
+ *
58
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
59
+ */
60
+ function createTransactionSearchBuilder() {
61
+ // eslint-disable-next-line composurecdk/builder-must-be-tagged -- AWS::XRay::TransactionSearchConfig has no Tags property
62
+ return (0, core_1.Builder)(TransactionSearchBuilder);
63
+ }
64
+ //# sourceMappingURL=transaction-search-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-search-builder.js","sourceRoot":"","sources":["../../src/transaction-search-builder.ts"],"names":[],"mappings":";;AAuFA,wEAGC;AA1FD,6CAA+C;AAC/C,iDAAwE;AACxE,mDAAsD;AACtD,mDAG8B;AAE9B,6CAA4E;AAC5E,+CAA4D;AAuB5D,mDAAmD;AACnD,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,+BAA+B,CAAC,CAAC;AAEvE,MAAM,wBAAwB;IAC5B,KAAK,GAA2C,EAAE,CAAC;IAEnD,KAAK,CAAC,KAAiB,EAAE,EAAU;QACjC,MAAM,KAAK,GAAG,mBAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,cAAc,GAAG,IAAI,yBAAc,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE;YAClE,gBAAgB,EAAE;gBAChB,IAAI,yBAAe,CAAC;oBAClB,GAAG,EAAE,6BAA6B;oBAClC,UAAU,EAAE,CAAC,IAAI,0BAAgB,CAAC,oBAAoB,CAAC,CAAC;oBACxD,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtC,KAAK,CAAC,SAAS,CAAC;wBACd,OAAO,EAAE,MAAM;wBACf,QAAQ,EAAE,WAAW;wBACrB,YAAY,EAAE,GAAG,IAAI,IAAI;wBACzB,SAAS,EAAE,uBAAS,CAAC,mBAAmB;qBACzC,CAAC,CACH;oBACD,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC;gCAC/B,OAAO,EAAE,MAAM;gCACf,QAAQ,EAAE,GAAG;gCACb,SAAS,EAAE,uBAAS,CAAC,gBAAgB;6BACtC,CAAC;yBACH;wBACD,YAAY,EAAE,EAAE,mBAAmB,EAAE,KAAK,CAAC,OAAO,EAAE;qBACrD;iBACF,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,iBAAiB,GAAG,IAAI,qCAA0B,CAAC,KAAK,EAAE,EAAE,EAAE;YAClE,GAAG,yCAA2B;YAC9B,GAAG,IAAI,CAAC,KAAK;SACd,CAAC,CAAC;QACH,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC;IAC/C,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,SAAgB,8BAA8B;IAC5C,0HAA0H;IAC1H,OAAO,IAAA,cAAO,EAA0D,wBAAwB,CAAC,CAAC;AACpG,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CfnTransactionSearchConfigProps } from "aws-cdk-lib/aws-xray";
2
+ /**
3
+ * Defaults applied by {@link createTransactionSearchBuilder}. Each can be
4
+ * overridden through the builder.
5
+ */
6
+ export declare const TRANSACTION_SEARCH_DEFAULTS: Partial<CfnTransactionSearchConfigProps>;
7
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,+BAA+B,CAOhF,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Defaults applied by {@link createTransactionSearchBuilder}. Each can be
3
+ * overridden through the builder.
4
+ */
5
+ export const TRANSACTION_SEARCH_DEFAULTS = {
6
+ /**
7
+ * Index 1% of spans as trace summaries: free, and AWS's default. Every span
8
+ * is still ingested and searchable.
9
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
10
+ */
11
+ indexingPercentage: 1,
12
+ };
13
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA6C;IACnF;;;;OAIG;IACH,kBAAkB,EAAE,CAAC;CACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { TRANSACTION_SEARCH_DEFAULTS } from "./defaults.js";
2
+ export { createTransactionSearchBuilder, type ITransactionSearchBuilder, type TransactionSearchBuilderProps, type TransactionSearchBuilderResult, } from "./transaction-search-builder.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,8BAA8B,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { TRANSACTION_SEARCH_DEFAULTS } from "./defaults.js";
2
+ export { createTransactionSearchBuilder, } from "./transaction-search-builder.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,8BAA8B,GAI/B,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,36 @@
1
+ import { ResourcePolicy } from "aws-cdk-lib/aws-logs";
2
+ import { CfnTransactionSearchConfig, type CfnTransactionSearchConfigProps } from "aws-cdk-lib/aws-xray";
3
+ import type { IConstruct } from "constructs";
4
+ import { type IBuilder, type Lifecycle } from "@composurecdk/core";
5
+ /** Configuration properties for {@link createTransactionSearchBuilder}. */
6
+ export type TransactionSearchBuilderProps = CfnTransactionSearchConfigProps;
7
+ /** The build output of an {@link ITransactionSearchBuilder}. */
8
+ export interface TransactionSearchBuilderResult {
9
+ transactionSearch: CfnTransactionSearchConfig;
10
+ /** Lets X-Ray write spans to CloudWatch Logs. */
11
+ resourcePolicy: ResourcePolicy;
12
+ }
13
+ /**
14
+ * A fluent builder that enables CloudWatch Transaction Search.
15
+ *
16
+ * @see {@link createTransactionSearchBuilder}
17
+ */
18
+ export type ITransactionSearchBuilder = IBuilder<TransactionSearchBuilderProps, TransactionSearchBuilder>;
19
+ declare class TransactionSearchBuilder implements Lifecycle<TransactionSearchBuilderResult> {
20
+ props: Partial<TransactionSearchBuilderProps>;
21
+ build(scope: IConstruct, id: string): TransactionSearchBuilderResult;
22
+ }
23
+ /**
24
+ * Creates a builder that enables CloudWatch Transaction Search for the account
25
+ * and Region. Build it in exactly one stack.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * createTransactionSearchBuilder().build(stack, "TransactionSearch");
30
+ * ```
31
+ *
32
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
33
+ */
34
+ export declare function createTransactionSearchBuilder(): ITransactionSearchBuilder;
35
+ export {};
36
+ //# sourceMappingURL=transaction-search-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-search-builder.d.ts","sourceRoot":"","sources":["../../src/transaction-search-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG5E,2EAA2E;AAC3E,MAAM,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAE5E,gEAAgE;AAChE,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,EAAE,0BAA0B,CAAC;IAC9C,iDAAiD;IACjD,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;GAIG;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,6BAA6B,EAC7B,wBAAwB,CACzB,CAAC;AAKF,cAAM,wBAAyB,YAAW,SAAS,CAAC,8BAA8B,CAAC;IACjF,KAAK,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAM;IAEnD,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,8BAA8B;CAoCrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,IAAI,yBAAyB,CAG1E"}
@@ -0,0 +1,61 @@
1
+ import { ArnFormat, Stack } from "aws-cdk-lib";
2
+ import { PolicyStatement, ServicePrincipal } from "aws-cdk-lib/aws-iam";
3
+ import { ResourcePolicy } from "aws-cdk-lib/aws-logs";
4
+ import { CfnTransactionSearchConfig, } from "aws-cdk-lib/aws-xray";
5
+ import { Builder } from "@composurecdk/core";
6
+ import { TRANSACTION_SEARCH_DEFAULTS } from "./defaults.js";
7
+ /** The log groups Transaction Search writes to. */
8
+ const SPAN_LOG_GROUPS = ["aws/spans", "/aws/application-signals/data"];
9
+ class TransactionSearchBuilder {
10
+ props = {};
11
+ build(scope, id) {
12
+ const stack = Stack.of(scope);
13
+ const resourcePolicy = new ResourcePolicy(scope, `${id}LogsPolicy`, {
14
+ policyStatements: [
15
+ new PolicyStatement({
16
+ sid: "TransactionSearchXRayAccess",
17
+ principals: [new ServicePrincipal("xray.amazonaws.com")],
18
+ actions: ["logs:PutLogEvents"],
19
+ resources: SPAN_LOG_GROUPS.map((name) => stack.formatArn({
20
+ service: "logs",
21
+ resource: "log-group",
22
+ resourceName: `${name}:*`,
23
+ arnFormat: ArnFormat.COLON_RESOURCE_NAME,
24
+ })),
25
+ conditions: {
26
+ ArnLike: {
27
+ "aws:SourceArn": stack.formatArn({
28
+ service: "xray",
29
+ resource: "*",
30
+ arnFormat: ArnFormat.NO_RESOURCE_NAME,
31
+ }),
32
+ },
33
+ StringEquals: { "aws:SourceAccount": stack.account },
34
+ },
35
+ }),
36
+ ],
37
+ });
38
+ const transactionSearch = new CfnTransactionSearchConfig(scope, id, {
39
+ ...TRANSACTION_SEARCH_DEFAULTS,
40
+ ...this.props,
41
+ });
42
+ transactionSearch.node.addDependency(resourcePolicy);
43
+ return { transactionSearch, resourcePolicy };
44
+ }
45
+ }
46
+ /**
47
+ * Creates a builder that enables CloudWatch Transaction Search for the account
48
+ * and Region. Build it in exactly one stack.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * createTransactionSearchBuilder().build(stack, "TransactionSearch");
53
+ * ```
54
+ *
55
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Enable-TransactionSearch.html
56
+ */
57
+ export function createTransactionSearchBuilder() {
58
+ // eslint-disable-next-line composurecdk/builder-must-be-tagged -- AWS::XRay::TransactionSearchConfig has no Tags property
59
+ return Builder(TransactionSearchBuilder);
60
+ }
61
+ //# sourceMappingURL=transaction-search-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-search-builder.js","sourceRoot":"","sources":["../../src/transaction-search-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,0BAA0B,GAE3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAiC,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAuB5D,mDAAmD;AACnD,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,+BAA+B,CAAC,CAAC;AAEvE,MAAM,wBAAwB;IAC5B,KAAK,GAA2C,EAAE,CAAC;IAEnD,KAAK,CAAC,KAAiB,EAAE,EAAU;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE;YAClE,gBAAgB,EAAE;gBAChB,IAAI,eAAe,CAAC;oBAClB,GAAG,EAAE,6BAA6B;oBAClC,UAAU,EAAE,CAAC,IAAI,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;oBACxD,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACtC,KAAK,CAAC,SAAS,CAAC;wBACd,OAAO,EAAE,MAAM;wBACf,QAAQ,EAAE,WAAW;wBACrB,YAAY,EAAE,GAAG,IAAI,IAAI;wBACzB,SAAS,EAAE,SAAS,CAAC,mBAAmB;qBACzC,CAAC,CACH;oBACD,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC;gCAC/B,OAAO,EAAE,MAAM;gCACf,QAAQ,EAAE,GAAG;gCACb,SAAS,EAAE,SAAS,CAAC,gBAAgB;6BACtC,CAAC;yBACH;wBACD,YAAY,EAAE,EAAE,mBAAmB,EAAE,KAAK,CAAC,OAAO,EAAE;qBACrD;iBACF,CAAC;aACH;SACF,CAAC,CAAC;QACH,MAAM,iBAAiB,GAAG,IAAI,0BAA0B,CAAC,KAAK,EAAE,EAAE,EAAE;YAClE,GAAG,2BAA2B;YAC9B,GAAG,IAAI,CAAC,KAAK;SACd,CAAC,CAAC;QACH,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC;IAC/C,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B;IAC5C,0HAA0H;IAC1H,OAAO,OAAO,CAA0D,wBAAwB,CAAC,CAAC;AACpG,CAAC"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@composurecdk/xray",
3
+ "version": "0.10.2",
4
+ "description": "Composable AWS X-Ray: account-level CloudWatch Transaction Search",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/laazyj/composureCDK.git",
8
+ "directory": "packages/xray"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "keywords": [
16
+ "aws",
17
+ "cdk",
18
+ "aws-cdk",
19
+ "infrastructure-as-code",
20
+ "iac",
21
+ "composurecdk",
22
+ "xray",
23
+ "tracing",
24
+ "observability",
25
+ "transaction-search"
26
+ ],
27
+ "author": "Jason Duffett (https://github.com/laazyj)",
28
+ "license": "MIT",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "type": "module",
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "tshy": {
37
+ "exports": {
38
+ "./package.json": "./package.json",
39
+ ".": "./src/index.ts"
40
+ }
41
+ },
42
+ "peerDependencies": {
43
+ "@composurecdk/core": "^0.10.0",
44
+ "aws-cdk-lib": "^2.183.0",
45
+ "constructs": "^10.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@composurecdk/cdk-testing": "*",
49
+ "@types/node": "^26.6.1",
50
+ "aws-cdk-lib": "^2.269.0",
51
+ "constructs": "^10.8.1",
52
+ "typescript": "^6.0.3",
53
+ "vitest": "^5.0.0"
54
+ },
55
+ "exports": {
56
+ "./package.json": "./package.json",
57
+ ".": {
58
+ "import": {
59
+ "types": "./dist/esm/index.d.ts",
60
+ "default": "./dist/esm/index.js"
61
+ },
62
+ "require": {
63
+ "types": "./dist/commonjs/index.d.ts",
64
+ "default": "./dist/commonjs/index.js"
65
+ }
66
+ }
67
+ },
68
+ "main": "./dist/commonjs/index.js",
69
+ "types": "./dist/commonjs/index.d.ts",
70
+ "module": "./dist/esm/index.js",
71
+ "nx": {
72
+ "tags": [
73
+ "scope:lib"
74
+ ]
75
+ }
76
+ }