@kensio/yulin 1.19.3 → 1.19.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/dist/serve/http/local-server/sim-aws-local-server.d.ts +7 -5
- package/dist/serve/http/local-server/sim-aws-local-server.d.ts.map +1 -1
- package/dist/serve/http/local-server/sim-aws-local-server.js.map +1 -1
- package/dist/serve/message/sim-email-log-block.d.ts +35 -0
- package/dist/serve/message/sim-email-log-block.d.ts.map +1 -0
- package/dist/serve/message/sim-email-log-block.js +111 -0
- package/dist/serve/message/sim-email-log-block.js.map +1 -0
- package/dist/serve/message/sim-local-message-logging.d.ts.map +1 -1
- package/dist/serve/message/sim-local-message-logging.js +4 -1
- package/dist/serve/message/sim-local-message-logging.js.map +1 -1
- package/dist/serve/message/sim-message-indent.d.ts +10 -0
- package/dist/serve/message/sim-message-indent.d.ts.map +1 -0
- package/dist/serve/message/sim-message-indent.js +12 -0
- package/dist/serve/message/sim-message-indent.js.map +1 -0
- package/dist/serve/message/sim-message-log-console.d.ts +17 -1
- package/dist/serve/message/sim-message-log-console.d.ts.map +1 -1
- package/dist/serve/message/sim-message-log-console.js +25 -17
- package/dist/serve/message/sim-message-log-console.js.map +1 -1
- package/dist/serve/message/sim-message-logging.d.ts +16 -3
- package/dist/serve/message/sim-message-logging.d.ts.map +1 -1
- package/dist/serve/message/sim-message-logging.js +28 -7
- package/dist/serve/message/sim-message-logging.js.map +1 -1
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +10 -0
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts.map +1 -1
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +15 -0
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.js.map +1 -1
- package/dist/service/aws/factory/sim-aws-self-contained-service-builder.d.ts +0 -9
- package/dist/service/aws/factory/sim-aws-self-contained-service-builder.d.ts.map +1 -1
- package/dist/service/aws/factory/sim-aws-self-contained-service-builder.js +0 -11
- package/dist/service/aws/factory/sim-aws-self-contained-service-builder.js.map +1 -1
- package/dist/service/aws/factory/sim-aws-service-factory.js +1 -1
- package/dist/service/aws/message/sim-aws-logged-message.d.ts +25 -5
- package/dist/service/aws/message/sim-aws-logged-message.d.ts.map +1 -1
- package/dist/service/cloudformation/bind/{sim-cfn-deploy-binding.d.ts → sim-cfn-binding.d.ts} +11 -4
- package/dist/service/cloudformation/bind/sim-cfn-binding.d.ts.map +1 -0
- package/dist/service/cloudformation/bind/{sim-cfn-deploy-binding.js → sim-cfn-binding.js} +1 -1
- package/dist/service/cloudformation/bind/sim-cfn-binding.js.map +1 -0
- package/dist/service/cloudformation/bind/sim-cfn-exec-binding.type.d.ts +32 -35
- package/dist/service/cloudformation/bind/sim-cfn-exec-binding.type.d.ts.map +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-finder.d.ts +2 -2
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-finder.d.ts.map +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-finder.js +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-finder.js.map +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-validator.d.ts +2 -2
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-validator.d.ts.map +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-validator.js +1 -1
- package/dist/service/cloudformation/bind/validate/sim-cfn-exec-binding-validator.js.map +1 -1
- package/dist/service/cloudformation/command/create-stack/create-stack.handler.d.ts +2 -2
- package/dist/service/cloudformation/command/create-stack/create-stack.handler.d.ts.map +1 -1
- package/dist/service/cloudformation/command/create-stack/create-stack.handler.js.map +1 -1
- package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-stack-options.d.ts +2 -2
- package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-stack-options.d.ts.map +1 -1
- package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.d.ts +2 -2
- package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.d.ts.map +1 -1
- package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.js.map +1 -1
- package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.d.ts +3 -3
- package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.d.ts.map +1 -1
- package/dist/service/cloudformation/index.d.ts +3 -0
- package/dist/service/cloudformation/index.d.ts.map +1 -1
- package/dist/service/cloudformation/resource/sim-cfn-resource.type.d.ts +2 -2
- package/dist/service/cloudformation/resource/sim-cfn-resource.type.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-batch-creator.d.ts +2 -2
- package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-batch-creator.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-batch-creator.js.map +1 -1
- package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-creator.d.ts +2 -2
- package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-creator.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-deployed-stack.type.d.ts +8 -0
- package/dist/service/cloudformation/stack/sim-cfn-deployed-stack.type.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.d.ts +2 -2
- package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.js.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-stack.d.ts +3 -10
- package/dist/service/cloudformation/stack/sim-cfn-stack.d.ts.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-stack.js +13 -18
- package/dist/service/cloudformation/stack/sim-cfn-stack.js.map +1 -1
- package/dist/service/cloudformation/stack/sim-cfn-stack.type.d.ts +2 -2
- package/dist/service/cloudformation/stack/sim-cfn-stack.type.d.ts.map +1 -1
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-binding-lookup.d.ts +2 -2
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-binding-lookup.d.ts.map +1 -1
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-create-input-builder.d.ts +2 -2
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-create-input-builder.d.ts.map +1 -1
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-create-input-builder.js.map +1 -1
- package/dist/service/ecs/cfn/bind/sim-cfn-ecs-container-binding.type.d.ts +1 -1
- package/dist/service/ecs/cfn/bind/sim-cfn-ecs-container-bindings.d.ts +2 -2
- package/dist/service/ecs/cfn/bind/sim-cfn-ecs-container-bindings.d.ts.map +1 -1
- package/dist/service/ecs/cfn/bind/sim-cfn-ecs-container-bindings.js +1 -1
- package/dist/service/ecs/cfn/bind/sim-cfn-ecs-container-bindings.js.map +1 -1
- package/dist/service/ecs/cfn/task-definition/sim-cfn-ecs-task-definition-creator.d.ts +2 -2
- package/dist/service/ecs/cfn/task-definition/sim-cfn-ecs-task-definition-creator.d.ts.map +1 -1
- package/dist/service/ecs/cfn/task-definition/sim-cfn-ecs-task-definition-creator.js.map +1 -1
- package/dist/service/lambda/cfn/function/sim-cfn-lambda-code-input.d.ts +2 -2
- package/dist/service/lambda/cfn/function/sim-cfn-lambda-code-input.d.ts.map +1 -1
- package/dist/service/lambda/cfn/function/sim-cfn-lambda-function-creator.d.ts +2 -2
- package/dist/service/lambda/cfn/function/sim-cfn-lambda-function-creator.d.ts.map +1 -1
- package/dist/service/lambda/cfn/function/sim-cfn-lambda-function-creator.js.map +1 -1
- package/dist/service/ses/command/send/sim-ses-configuration-set-check.d.ts +53 -0
- package/dist/service/ses/command/send/sim-ses-configuration-set-check.d.ts.map +1 -0
- package/dist/service/ses/command/send/sim-ses-configuration-set-check.js +70 -0
- package/dist/service/ses/command/send/sim-ses-configuration-set-check.js.map +1 -0
- package/dist/service/ses/command/send/sim-ses-send-email.d.ts +5 -3
- package/dist/service/ses/command/send/sim-ses-send-email.d.ts.map +1 -1
- package/dist/service/ses/command/send/sim-ses-send-email.js +11 -4
- package/dist/service/ses/command/send/sim-ses-send-email.js.map +1 -1
- package/dist/service/ses/command/send/sim-ses-service-send.d.ts +6 -0
- package/dist/service/ses/command/send/sim-ses-service-send.d.ts.map +1 -1
- package/dist/service/ses/command/send/sim-ses-service-send.js +9 -2
- package/dist/service/ses/command/send/sim-ses-service-send.js.map +1 -1
- package/dist/service/ses/email/sim-ses-sent-email-store.d.ts +14 -0
- package/dist/service/ses/email/sim-ses-sent-email-store.d.ts.map +1 -1
- package/dist/service/ses/email/sim-ses-sent-email-store.js +21 -0
- package/dist/service/ses/email/sim-ses-sent-email-store.js.map +1 -1
- package/dist/service/ses/error/sim-ses.error.d.ts +12 -0
- package/dist/service/ses/error/sim-ses.error.d.ts.map +1 -1
- package/dist/service/ses/error/sim-ses.error.js +14 -0
- package/dist/service/ses/error/sim-ses.error.js.map +1 -1
- package/dist/service/ses/index.d.ts +1 -1
- package/dist/service/ses/index.d.ts.map +1 -1
- package/dist/service/ses/index.js +1 -1
- package/dist/service/ses/index.js.map +1 -1
- package/dist/service/ses/sim-ses-commands.d.ts +5 -0
- package/dist/service/ses/sim-ses-commands.d.ts.map +1 -1
- package/dist/service/ses/sim-ses-commands.js +10 -2
- package/dist/service/ses/sim-ses-commands.js.map +1 -1
- package/dist/terraform/sim-tf-adapter.d.ts +2 -2
- package/dist/terraform/sim-tf-adapter.d.ts.map +1 -1
- package/dist/terraform/sim-tf-attribute-intrinsic.d.ts +13 -0
- package/dist/terraform/sim-tf-attribute-intrinsic.d.ts.map +1 -0
- package/dist/terraform/sim-tf-attribute-intrinsic.js +23 -0
- package/dist/terraform/sim-tf-attribute-intrinsic.js.map +1 -0
- package/dist/terraform/sim-tf-attributes.js +1 -1
- package/dist/terraform/sim-tf-attributes.js.map +1 -1
- package/dist/terraform/sim-tf-declare.d.ts +0 -20
- package/dist/terraform/sim-tf-declare.d.ts.map +1 -1
- package/dist/terraform/sim-tf-declare.js +1 -47
- package/dist/terraform/sim-tf-declare.js.map +1 -1
- package/dist/terraform/sim-tf-depends-on.d.ts +21 -0
- package/dist/terraform/sim-tf-depends-on.d.ts.map +1 -0
- package/dist/terraform/sim-tf-depends-on.js +30 -0
- package/dist/terraform/sim-tf-depends-on.js.map +1 -0
- package/dist/terraform/sim-tf-expression-references.d.ts +11 -0
- package/dist/terraform/sim-tf-expression-references.d.ts.map +1 -0
- package/dist/terraform/sim-tf-expression-references.js +22 -0
- package/dist/terraform/sim-tf-expression-references.js.map +1 -0
- package/dist/terraform/sim-tf-module-outputs.d.ts +39 -0
- package/dist/terraform/sim-tf-module-outputs.d.ts.map +1 -1
- package/dist/terraform/sim-tf-module-outputs.js +66 -0
- package/dist/terraform/sim-tf-module-outputs.js.map +1 -1
- package/dist/terraform/sim-tf-module-variables.d.ts +16 -0
- package/dist/terraform/sim-tf-module-variables.d.ts.map +1 -0
- package/dist/terraform/sim-tf-module-variables.js +37 -0
- package/dist/terraform/sim-tf-module-variables.js.map +1 -0
- package/dist/terraform/sim-tf-nested-attributes.js +2 -2
- package/dist/terraform/sim-tf-nested-attributes.js.map +1 -1
- package/dist/terraform/sim-tf-plan-resources.d.ts.map +1 -1
- package/dist/terraform/sim-tf-plan-resources.js +2 -0
- package/dist/terraform/sim-tf-plan-resources.js.map +1 -1
- package/dist/terraform/sim-tf-plan.type.d.ts +20 -3
- package/dist/terraform/sim-tf-plan.type.d.ts.map +1 -1
- package/dist/terraform/sim-tf-reference-addresses.d.ts +45 -0
- package/dist/terraform/sim-tf-reference-addresses.d.ts.map +1 -0
- package/dist/terraform/sim-tf-reference-addresses.js +82 -0
- package/dist/terraform/sim-tf-reference-addresses.js.map +1 -0
- package/dist/terraform/sim-tf-reference-scope.d.ts +29 -0
- package/dist/terraform/sim-tf-reference-scope.d.ts.map +1 -0
- package/dist/terraform/sim-tf-reference-scope.js +71 -0
- package/dist/terraform/sim-tf-reference-scope.js.map +1 -0
- package/dist/terraform/sim-tf-reference.d.ts +33 -31
- package/dist/terraform/sim-tf-reference.d.ts.map +1 -1
- package/dist/terraform/sim-tf-reference.js +79 -88
- package/dist/terraform/sim-tf-reference.js.map +1 -1
- package/dist/terraform/sim-tf-referenced.js +1 -1
- package/dist/terraform/sim-tf-referenced.js.map +1 -1
- package/dist/terraform/sim-tf-resource.type.d.ts +8 -0
- package/dist/terraform/sim-tf-resource.type.d.ts.map +1 -1
- package/dist/terraform/sim-tf-settle.d.ts.map +1 -1
- package/dist/terraform/sim-tf-settle.js +3 -1
- package/dist/terraform/sim-tf-settle.js.map +1 -1
- package/dist/util/exactly-one.type.d.ts +14 -0
- package/dist/util/exactly-one.type.d.ts.map +1 -0
- package/dist/util/exactly-one.type.js +2 -0
- package/dist/util/exactly-one.type.js.map +1 -0
- package/package.json +1 -1
- package/dist/service/cloudformation/bind/sim-cfn-deploy-binding.d.ts.map +0 -1
- package/dist/service/cloudformation/bind/sim-cfn-deploy-binding.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TerraformResource } from "./sim-tf-resource.type.js";
|
|
2
|
+
/**
|
|
3
|
+
* The resources a template will declare, looked up by the addresses that name
|
|
4
|
+
* them.
|
|
5
|
+
*
|
|
6
|
+
* A reference is text, and finding the resource behind it is a search over
|
|
7
|
+
* addresses rather than a lookup, because the reference carries the attribute
|
|
8
|
+
* being read and may leave out the instance key. Both searches are here, away
|
|
9
|
+
* from the resolver deciding what to do with what they find.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TerraformResourceAddresses {
|
|
12
|
+
private readonly byAddress;
|
|
13
|
+
constructor(resources: readonly TerraformResource[]);
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
/** Every address this template will declare a Resource under. */
|
|
18
|
+
addresses(): Iterable<string>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
/** The resource one address names exactly. */
|
|
23
|
+
get(address: string): TerraformResource | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The resource whose address is the longest prefix of this reference.
|
|
26
|
+
*
|
|
27
|
+
* `aws_iam_role.processor.arn` has to find `aws_iam_role.processor` and leave
|
|
28
|
+
* `arn` behind, and a `for_each` instance address carries a bracketed key
|
|
29
|
+
* that is part of the address rather than an attribute.
|
|
30
|
+
*/
|
|
31
|
+
longestMatch(qualified: string): TerraformResource | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* One instance of a resource a reference named without its key.
|
|
34
|
+
*
|
|
35
|
+
* `aws_apigatewayv2_integration.this[each.key]` is written into a plan as a
|
|
36
|
+
* reference to `aws_apigatewayv2_integration.this` and a separate reference
|
|
37
|
+
* to `each.key`, so the address in hand names no instance. The instance
|
|
38
|
+
* meant is the one keyed like the resource doing the reading, since that is
|
|
39
|
+
* what `each.key` holds there, and a resource with one instance and no key
|
|
40
|
+
* to go on has only the one it could mean.
|
|
41
|
+
*/
|
|
42
|
+
instance(qualified: string, index: string | number | undefined): string | undefined;
|
|
43
|
+
private soleInstance;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=sim-tf-reference-addresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-tf-reference-addresses.d.ts","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference-addresses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;GAQG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyC;IAEnE,YAAY,SAAS,EAAE,SAAS,iBAAiB,EAAE,EAIlD;IAED;;OAEG;IACH,iEAAiE;IAC1D,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,CAEnC;IAED;;OAEG;IACH,8CAA8C;IACvC,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEzD;IAED;;;;;;OAMG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAcpE;IAED;;;;;;;;;OASG;IACI,QAAQ,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GACjC,MAAM,GAAG,SAAS,CAQpB;IAED,OAAO,CAAC,YAAY;CAQrB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resources a template will declare, looked up by the addresses that name
|
|
3
|
+
* them.
|
|
4
|
+
*
|
|
5
|
+
* A reference is text, and finding the resource behind it is a search over
|
|
6
|
+
* addresses rather than a lookup, because the reference carries the attribute
|
|
7
|
+
* being read and may leave out the instance key. Both searches are here, away
|
|
8
|
+
* from the resolver deciding what to do with what they find.
|
|
9
|
+
*/
|
|
10
|
+
export class TerraformResourceAddresses {
|
|
11
|
+
byAddress;
|
|
12
|
+
constructor(resources) {
|
|
13
|
+
this.byAddress = new Map(resources.map((resource) => [resource.address, resource]));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
/** Every address this template will declare a Resource under. */
|
|
19
|
+
addresses() {
|
|
20
|
+
return this.byAddress.keys();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
/** The resource one address names exactly. */
|
|
26
|
+
get(address) {
|
|
27
|
+
return this.byAddress.get(address);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The resource whose address is the longest prefix of this reference.
|
|
31
|
+
*
|
|
32
|
+
* `aws_iam_role.processor.arn` has to find `aws_iam_role.processor` and leave
|
|
33
|
+
* `arn` behind, and a `for_each` instance address carries a bracketed key
|
|
34
|
+
* that is part of the address rather than an attribute.
|
|
35
|
+
*/
|
|
36
|
+
longestMatch(qualified) {
|
|
37
|
+
let best;
|
|
38
|
+
for (const [address, resource] of this.byAddress) {
|
|
39
|
+
if (qualified !== address && !qualified.startsWith(`${address}.`)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (best === undefined || address.length > best.address.length) {
|
|
43
|
+
best = resource;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return best;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One instance of a resource a reference named without its key.
|
|
50
|
+
*
|
|
51
|
+
* `aws_apigatewayv2_integration.this[each.key]` is written into a plan as a
|
|
52
|
+
* reference to `aws_apigatewayv2_integration.this` and a separate reference
|
|
53
|
+
* to `each.key`, so the address in hand names no instance. The instance
|
|
54
|
+
* meant is the one keyed like the resource doing the reading, since that is
|
|
55
|
+
* what `each.key` holds there, and a resource with one instance and no key
|
|
56
|
+
* to go on has only the one it could mean.
|
|
57
|
+
*/
|
|
58
|
+
instance(qualified, index) {
|
|
59
|
+
const keyed = instanceAddress(qualified, index);
|
|
60
|
+
if (keyed !== undefined && this.byAddress.has(keyed)) {
|
|
61
|
+
return keyed;
|
|
62
|
+
}
|
|
63
|
+
return this.soleInstance(qualified);
|
|
64
|
+
}
|
|
65
|
+
soleInstance(qualified) {
|
|
66
|
+
const instances = this.byAddress
|
|
67
|
+
.keys()
|
|
68
|
+
.filter((address) => address.startsWith(`${qualified}[`))
|
|
69
|
+
.toArray();
|
|
70
|
+
return instances.length === 1 ? instances[0] : undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** One address written with the `count` or `for_each` key of an instance. */
|
|
74
|
+
function instanceAddress(qualified, index) {
|
|
75
|
+
if (index === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return typeof index === "number"
|
|
79
|
+
? `${qualified}[${index}]`
|
|
80
|
+
: `${qualified}["${index}"]`;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sim-tf-reference-addresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-tf-reference-addresses.js","sourceRoot":"","sources":["../../src/ter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AO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAEO,YAAY,CAAC,SAAiB;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS;aAC7B,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;aACxD,OAAO,EAAE,CAAC;QAEb,OAAO,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,CAAC;CACF;AAED,6EAA6E;AAC7E,SAAS,eAAe,CACtB,SAAiB,EACjB,KAAkC;IAElC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,GAAG,SAAS,IAAI,KAAK,GAAG;QAC1B,CAAC,CAAC,GAAG,SAAS,KAAK,KAAK,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TerraformResource } from "./sim-tf-resource.type.js";
|
|
2
|
+
/** One reference to follow, and the module its own references are written in. */
|
|
3
|
+
export interface TerraformScopeHop {
|
|
4
|
+
readonly reference: string;
|
|
5
|
+
readonly modulePath: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What a reference Terraform resolves for itself stands in for.
|
|
9
|
+
*
|
|
10
|
+
* `each.value.uri` and `var.routes` name no address, and a plan resolves
|
|
11
|
+
* neither to a value where the value is not known yet. What a plan does record
|
|
12
|
+
* is where each one was written from. A `for_each` expression says what the
|
|
13
|
+
* collection was built out of, and a module call says what the caller set each
|
|
14
|
+
* variable to, so following one of these is following a reference written
|
|
15
|
+
* somewhere else.
|
|
16
|
+
*
|
|
17
|
+
* The step is a rewrite rather than an evaluation. `each.value.uri` becomes
|
|
18
|
+
* the references of the collection `each` iterates, in the module that
|
|
19
|
+
* declared the resource, and `var.routes` becomes the references of the module
|
|
20
|
+
* call, in the module that made it.
|
|
21
|
+
*
|
|
22
|
+
* What is lost either way is which part of the collection was being read.
|
|
23
|
+
* A plan records the references of a `routes` map as one list, with nothing to
|
|
24
|
+
* say which route or which of its keys each one belongs to, so `each.value.uri`
|
|
25
|
+
* and `each.value.timeout_milliseconds` are written down identically. The
|
|
26
|
+
* caller is what decides that an ambiguous answer is no answer.
|
|
27
|
+
*/
|
|
28
|
+
export declare function terraformScopeHops(reference: string, modulePath: readonly string[], from: TerraformResource, moduleVariables: ReadonlyMap<string, readonly string[]>, depth: number): readonly TerraformScopeHop[];
|
|
29
|
+
//# sourceMappingURL=sim-tf-reference-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-tf-reference-scope.d.ts","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAMnE,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,IAAI,EAAE,iBAAiB,EACvB,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EACvD,KAAK,EAAE,MAAM,GACZ,SAAS,iBAAiB,EAAE,CAU9B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { longestFirst, withoutInstanceKeys, } from "./sim-tf-reference-address.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a reference Terraform resolves for itself stands in for.
|
|
4
|
+
*
|
|
5
|
+
* `each.value.uri` and `var.routes` name no address, and a plan resolves
|
|
6
|
+
* neither to a value where the value is not known yet. What a plan does record
|
|
7
|
+
* is where each one was written from. A `for_each` expression says what the
|
|
8
|
+
* collection was built out of, and a module call says what the caller set each
|
|
9
|
+
* variable to, so following one of these is following a reference written
|
|
10
|
+
* somewhere else.
|
|
11
|
+
*
|
|
12
|
+
* The step is a rewrite rather than an evaluation. `each.value.uri` becomes
|
|
13
|
+
* the references of the collection `each` iterates, in the module that
|
|
14
|
+
* declared the resource, and `var.routes` becomes the references of the module
|
|
15
|
+
* call, in the module that made it.
|
|
16
|
+
*
|
|
17
|
+
* What is lost either way is which part of the collection was being read.
|
|
18
|
+
* A plan records the references of a `routes` map as one list, with nothing to
|
|
19
|
+
* say which route or which of its keys each one belongs to, so `each.value.uri`
|
|
20
|
+
* and `each.value.timeout_milliseconds` are written down identically. The
|
|
21
|
+
* caller is what decides that an ambiguous answer is no answer.
|
|
22
|
+
*/
|
|
23
|
+
export function terraformScopeHops(reference, modulePath, from, moduleVariables, depth) {
|
|
24
|
+
if (reference.startsWith("each.")) {
|
|
25
|
+
return eachHops(modulePath, from, depth);
|
|
26
|
+
}
|
|
27
|
+
if (reference.startsWith("var.")) {
|
|
28
|
+
return variableHops(reference, modulePath, moduleVariables);
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The collection `each` iterates, read from the resource doing the reading.
|
|
34
|
+
*
|
|
35
|
+
* Only the resource whose own expression held the reference has an `each` to
|
|
36
|
+
* read, which is the reference at depth zero. A reference reached by an
|
|
37
|
+
* earlier hop was written in another module, against another resource's
|
|
38
|
+
* collection, and is left alone.
|
|
39
|
+
*/
|
|
40
|
+
function eachHops(modulePath, from, depth) {
|
|
41
|
+
if (depth > 0) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return longestFirst(from.forEach).map((reference) => ({
|
|
45
|
+
reference,
|
|
46
|
+
modulePath,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What the caller set one of a module's variables to.
|
|
51
|
+
*
|
|
52
|
+
* The index is keyed by call path, since a module declares its variables once
|
|
53
|
+
* however many instances of the call there are, and the references the caller
|
|
54
|
+
* wrote are relative to the module holding the call.
|
|
55
|
+
*/
|
|
56
|
+
function variableHops(reference, modulePath, moduleVariables) {
|
|
57
|
+
if (modulePath.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const call = modulePath
|
|
61
|
+
.map((name) => `module.${withoutInstanceKeys(name)}`)
|
|
62
|
+
.join(".");
|
|
63
|
+
const name = reference.split(".", 2)[1] ?? "";
|
|
64
|
+
const set = moduleVariables.get(`${call}.var.${name}`) ?? [];
|
|
65
|
+
const caller = modulePath.slice(0, -1);
|
|
66
|
+
return longestFirst(set).map((written) => ({
|
|
67
|
+
reference: written,
|
|
68
|
+
modulePath: caller,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=sim-tf-reference-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-tf-reference-scope.js","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference-scope.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAQvC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,UAA6B,EAC7B,IAAuB,EACvB,eAAuD,EACvD,KAAa;IAEb,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,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
@@ -7,16 +7,24 @@ import type { TerraformResource } from "./sim-tf-resource.type.js";
|
|
|
7
7
|
* Terraform lists both forms for the same reference, so the longest address
|
|
8
8
|
* matching a resource wins and what is left over is the attribute.
|
|
9
9
|
*
|
|
10
|
+
* A reference naming no address at all is followed to one that does. Module
|
|
11
|
+
* outputs, module variables, `each` and an instance key left to `each.key` are
|
|
12
|
+
* each recorded somewhere else in the plan, and following them is a rewrite
|
|
13
|
+
* from one reference to another rather than an evaluation. Nothing here reads
|
|
14
|
+
* a Terraform expression, and a value the plan marked unknown stays unknown.
|
|
15
|
+
* What comes back is the resource that will produce it.
|
|
16
|
+
*
|
|
10
17
|
* The resources given are the ones the template will hold, rather than every
|
|
11
18
|
* resource of the plan. A reference to a resource the template does not
|
|
12
19
|
* declare resolves to nothing, so no property can come out of this naming a
|
|
13
20
|
* logical ID that is not there.
|
|
14
21
|
*/
|
|
15
22
|
export declare class TerraformReferenceResolver {
|
|
16
|
-
private readonly
|
|
23
|
+
private readonly resources;
|
|
17
24
|
private readonly moduleOutputs;
|
|
25
|
+
private readonly moduleVariables;
|
|
18
26
|
private readonly logicalIds;
|
|
19
|
-
constructor(resources: readonly TerraformResource[], moduleOutputs?: ReadonlyMap<string, readonly string[]>);
|
|
27
|
+
constructor(resources: readonly TerraformResource[], moduleOutputs?: ReadonlyMap<string, readonly string[]>, moduleVariables?: ReadonlyMap<string, readonly string[]>);
|
|
20
28
|
/** The logical ID the template declares one address under. */
|
|
21
29
|
logicalId(address: string): string;
|
|
22
30
|
/**
|
|
@@ -32,7 +40,7 @@ export declare class TerraformReferenceResolver {
|
|
|
32
40
|
* and so does one whose attribute has no entry in the read table. The caller
|
|
33
41
|
* decides what an unresolvable reference means for the Resource holding it.
|
|
34
42
|
*/
|
|
35
|
-
resolve(reference: string,
|
|
43
|
+
resolve(reference: string, from: TerraformResource): SimCfnTemplateValue | undefined;
|
|
36
44
|
/**
|
|
37
45
|
* The address of the resource one reference names.
|
|
38
46
|
*
|
|
@@ -40,7 +48,28 @@ export declare class TerraformReferenceResolver {
|
|
|
40
48
|
* off it, because it is merging properties into that resource's template,
|
|
41
49
|
* and so does the ordering pass.
|
|
42
50
|
*/
|
|
43
|
-
targetAddress(reference: string,
|
|
51
|
+
targetAddress(reference: string, from: TerraformResource): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The same reference, written so that it names a resource of this plan.
|
|
54
|
+
*
|
|
55
|
+
* A reference that already names one is itself. One that names an instance
|
|
56
|
+
* without its key gains the key. One under a scope the plan resolves for
|
|
57
|
+
* itself is replaced by what was written where that scope was set, and then
|
|
58
|
+
* asked again.
|
|
59
|
+
*/
|
|
60
|
+
private named;
|
|
61
|
+
/**
|
|
62
|
+
* The one resource a scoped reference leads to, where there is only one.
|
|
63
|
+
*
|
|
64
|
+
* A plan records the references of a whole collection as one list and says
|
|
65
|
+
* nothing about which part of it a reader was reading, so a collection built
|
|
66
|
+
* out of two resources cannot say which of them `each.value.uri` holds.
|
|
67
|
+
* Guessing there would put a plausible logical ID into a property that names
|
|
68
|
+
* the wrong resource, which is worse than the property being absent. Two
|
|
69
|
+
* answers is therefore no answer, and the resource is left out and reported
|
|
70
|
+
* the way it is today.
|
|
71
|
+
*/
|
|
72
|
+
private throughScope;
|
|
44
73
|
/**
|
|
45
74
|
* The attribute a reference reads off the resource behind it.
|
|
46
75
|
*
|
|
@@ -51,32 +80,5 @@ export declare class TerraformReferenceResolver {
|
|
|
51
80
|
*/
|
|
52
81
|
private attributeName;
|
|
53
82
|
private target;
|
|
54
|
-
/**
|
|
55
|
-
* The module output one reference names.
|
|
56
|
-
*
|
|
57
|
-
* The index is keyed by module call path, since a module declares its
|
|
58
|
-
* outputs once however many instances of the call there are. A reference
|
|
59
|
-
* made from inside one instance carries that instance's key, so the key
|
|
60
|
-
* comes off when the qualified form finds nothing.
|
|
61
|
-
*/
|
|
62
|
-
private moduleOutput;
|
|
63
|
-
/**
|
|
64
|
-
* The resource a module output leads to.
|
|
65
|
-
*
|
|
66
|
-
* The output's own expression names it, in terms of the module declaring the
|
|
67
|
-
* output, so following one is resolving that expression again one module
|
|
68
|
-
* down. An output built out of several resources returns the first that
|
|
69
|
-
* resolves, and the depth limit stops a module whose outputs refer to each
|
|
70
|
-
* other from looping.
|
|
71
|
-
*/
|
|
72
|
-
private throughModuleOutput;
|
|
73
|
-
/**
|
|
74
|
-
* The resource whose address is the longest prefix of this reference.
|
|
75
|
-
*
|
|
76
|
-
* `aws_iam_role.processor.arn` has to find `aws_iam_role.processor` and leave
|
|
77
|
-
* `arn` behind, and a `for_each` instance address carries a bracketed key
|
|
78
|
-
* that is part of the address rather than an attribute.
|
|
79
|
-
*/
|
|
80
|
-
private longestMatch;
|
|
81
83
|
}
|
|
82
84
|
//# sourceMappingURL=sim-tf-reference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-tf-reference.d.ts","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oEAAoE,CAAC;AAC9G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"sim-tf-reference.d.ts","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oEAAoE,CAAC;AAC9G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAWnE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IACvD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyC;IACzE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IAEjD,YACE,SAAS,EAAE,SAAS,iBAAiB,EAAE,EACvC,aAAa,GAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAa,EACjE,eAAe,GAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAa,EASpE;IAED,8DAA8D;IACvD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExC;IAED;;;;OAIG;IACI,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAE9D;IAED;;;;;;OAMG;IACI,OAAO,CACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,iBAAiB,GACtB,mBAAmB,GAAG,SAAS,CAajC;IAED;;;;;;OAMG;IACI,aAAa,CAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,iBAAiB,GACtB,MAAM,GAAG,SAAS,CAMpB;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;IAuBb;;;;;;;;;;OAUG;IACH,OAAO,CAAC,YAAY;IA4BpB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,MAAM;CAMf"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { terraformAttributeIntrinsic } from "./sim-tf-attribute-intrinsic.js";
|
|
2
2
|
import { TerraformLogicalIds } from "./sim-tf-logical-id.js";
|
|
3
|
-
import {
|
|
3
|
+
import { TerraformResourceAddresses } from "./sim-tf-reference-addresses.js";
|
|
4
|
+
import { TerraformModuleOutputWalk } from "./sim-tf-module-outputs.js";
|
|
5
|
+
import { terraformScopeHops } from "./sim-tf-reference-scope.js";
|
|
6
|
+
import { qualifiedReference } from "./sim-tf-reference-address.js";
|
|
7
|
+
/** How far a chain of hops is followed before it is taken to be a loop. */
|
|
8
|
+
const hopLimit = 8;
|
|
4
9
|
/**
|
|
5
10
|
* Resolves a Terraform reference against the resources a template declares.
|
|
6
11
|
*
|
|
@@ -8,19 +13,28 @@ import { longestFirst, moduleOutputPath, qualifiedReference, withoutInstanceKeys
|
|
|
8
13
|
* Terraform lists both forms for the same reference, so the longest address
|
|
9
14
|
* matching a resource wins and what is left over is the attribute.
|
|
10
15
|
*
|
|
16
|
+
* A reference naming no address at all is followed to one that does. Module
|
|
17
|
+
* outputs, module variables, `each` and an instance key left to `each.key` are
|
|
18
|
+
* each recorded somewhere else in the plan, and following them is a rewrite
|
|
19
|
+
* from one reference to another rather than an evaluation. Nothing here reads
|
|
20
|
+
* a Terraform expression, and a value the plan marked unknown stays unknown.
|
|
21
|
+
* What comes back is the resource that will produce it.
|
|
22
|
+
*
|
|
11
23
|
* The resources given are the ones the template will hold, rather than every
|
|
12
24
|
* resource of the plan. A reference to a resource the template does not
|
|
13
25
|
* declare resolves to nothing, so no property can come out of this naming a
|
|
14
26
|
* logical ID that is not there.
|
|
15
27
|
*/
|
|
16
28
|
export class TerraformReferenceResolver {
|
|
17
|
-
|
|
29
|
+
resources;
|
|
18
30
|
moduleOutputs;
|
|
31
|
+
moduleVariables;
|
|
19
32
|
logicalIds;
|
|
20
|
-
constructor(resources, moduleOutputs = new Map()) {
|
|
21
|
-
this.
|
|
22
|
-
this.moduleOutputs = moduleOutputs;
|
|
23
|
-
this.
|
|
33
|
+
constructor(resources, moduleOutputs = new Map(), moduleVariables = new Map()) {
|
|
34
|
+
this.resources = new TerraformResourceAddresses(resources);
|
|
35
|
+
this.moduleOutputs = new TerraformModuleOutputWalk(moduleOutputs, this.resources);
|
|
36
|
+
this.moduleVariables = moduleVariables;
|
|
37
|
+
this.logicalIds = new TerraformLogicalIds(this.resources.addresses());
|
|
24
38
|
}
|
|
25
39
|
/** The logical ID the template declares one address under. */
|
|
26
40
|
logicalId(address) {
|
|
@@ -32,7 +46,7 @@ export class TerraformReferenceResolver {
|
|
|
32
46
|
* own attribute refers to is what wants this.
|
|
33
47
|
*/
|
|
34
48
|
resource(address) {
|
|
35
|
-
return this.
|
|
49
|
+
return this.resources.get(address);
|
|
36
50
|
}
|
|
37
51
|
/**
|
|
38
52
|
* The CloudFormation value one reference stands for.
|
|
@@ -41,23 +55,13 @@ export class TerraformReferenceResolver {
|
|
|
41
55
|
* and so does one whose attribute has no entry in the read table. The caller
|
|
42
56
|
* decides what an unresolvable reference means for the Resource holding it.
|
|
43
57
|
*/
|
|
44
|
-
resolve(reference,
|
|
45
|
-
const qualified =
|
|
46
|
-
const target = this.target(qualified);
|
|
47
|
-
if (target === undefined) {
|
|
58
|
+
resolve(reference, from) {
|
|
59
|
+
const qualified = this.named(reference, from.modulePath, from, 0);
|
|
60
|
+
const target = qualified === undefined ? undefined : this.target(qualified);
|
|
61
|
+
if (qualified === undefined || target === undefined) {
|
|
48
62
|
return undefined;
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
const read = attribute === undefined
|
|
52
|
-
? "Ref"
|
|
53
|
-
: terraformAttributeReads.get(`${target.type}.${attribute}`);
|
|
54
|
-
if (read === undefined) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
const logicalId = this.logicalId(target.address);
|
|
58
|
-
return read === "Ref"
|
|
59
|
-
? { Ref: logicalId }
|
|
60
|
-
: { "Fn::GetAtt": [logicalId, read] };
|
|
64
|
+
return terraformAttributeIntrinsic(target.type, this.attributeName(qualified, target.address), this.logicalId(target.address));
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
67
|
* The address of the resource one reference names.
|
|
@@ -66,88 +70,75 @@ export class TerraformReferenceResolver {
|
|
|
66
70
|
* off it, because it is merging properties into that resource's template,
|
|
67
71
|
* and so does the ordering pass.
|
|
68
72
|
*/
|
|
69
|
-
targetAddress(reference,
|
|
70
|
-
|
|
73
|
+
targetAddress(reference, from) {
|
|
74
|
+
const qualified = this.named(reference, from.modulePath, from, 0);
|
|
75
|
+
return qualified === undefined
|
|
76
|
+
? undefined
|
|
77
|
+
: this.target(qualified)?.address;
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
|
-
* The
|
|
80
|
+
* The same reference, written so that it names a resource of this plan.
|
|
74
81
|
*
|
|
75
|
-
* A reference
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
82
|
+
* A reference that already names one is itself. One that names an instance
|
|
83
|
+
* without its key gains the key. One under a scope the plan resolves for
|
|
84
|
+
* itself is replaced by what was written where that scope was set, and then
|
|
85
|
+
* asked again.
|
|
79
86
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
named(reference, modulePath, from, depth) {
|
|
88
|
+
const qualified = qualifiedReference(reference, modulePath);
|
|
89
|
+
if (this.target(qualified) !== undefined) {
|
|
90
|
+
return qualified;
|
|
83
91
|
}
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
const keyed = this.resources.instance(qualified, from.index);
|
|
93
|
+
if (keyed !== undefined) {
|
|
94
|
+
return keyed;
|
|
86
95
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
target(qualified) {
|
|
91
|
-
return this.longestMatch(qualified) ?? this.throughModuleOutput(qualified);
|
|
96
|
+
return depth >= hopLimit
|
|
97
|
+
? undefined
|
|
98
|
+
: this.throughScope(reference, modulePath, from, depth);
|
|
92
99
|
}
|
|
93
100
|
/**
|
|
94
|
-
* The
|
|
101
|
+
* The one resource a scoped reference leads to, where there is only one.
|
|
95
102
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
103
|
+
* A plan records the references of a whole collection as one list and says
|
|
104
|
+
* nothing about which part of it a reader was reading, so a collection built
|
|
105
|
+
* out of two resources cannot say which of them `each.value.uri` holds.
|
|
106
|
+
* Guessing there would put a plausible logical ID into a property that names
|
|
107
|
+
* the wrong resource, which is worse than the property being absent. Two
|
|
108
|
+
* answers is therefore no answer, and the resource is left out and reported
|
|
109
|
+
* the way it is today.
|
|
100
110
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* output, so following one is resolving that expression again one module
|
|
110
|
-
* down. An output built out of several resources returns the first that
|
|
111
|
-
* resolves, and the depth limit stops a module whose outputs refer to each
|
|
112
|
-
* other from looping.
|
|
113
|
-
*/
|
|
114
|
-
throughModuleOutput(qualified, depth = 0) {
|
|
115
|
-
const output = this.moduleOutput(qualified);
|
|
116
|
-
if (output === undefined || depth > 8) {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
// The path the output was read through rather than the one it was
|
|
120
|
-
// declared under, so an output reached inside a `for_each` instance
|
|
121
|
-
// follows its own instance's resources.
|
|
122
|
-
const instance = moduleOutputPath(qualified);
|
|
123
|
-
for (const reference of longestFirst(output)) {
|
|
124
|
-
const nested = qualifiedReference(reference, instance);
|
|
125
|
-
const target = this.longestMatch(nested) ??
|
|
126
|
-
this.throughModuleOutput(nested, depth + 1);
|
|
127
|
-
if (target !== undefined) {
|
|
128
|
-
return target;
|
|
111
|
+
throughScope(reference, modulePath, from, depth) {
|
|
112
|
+
const hops = terraformScopeHops(reference, modulePath, from, this.moduleVariables, depth);
|
|
113
|
+
const found = new Map();
|
|
114
|
+
for (const hop of hops) {
|
|
115
|
+
const named = this.named(hop.reference, hop.modulePath, from, depth + 1);
|
|
116
|
+
const address = named === undefined ? undefined : this.target(named)?.address;
|
|
117
|
+
if (named !== undefined && address !== undefined && !found.has(address)) {
|
|
118
|
+
found.set(address, named);
|
|
129
119
|
}
|
|
130
120
|
}
|
|
131
|
-
return undefined;
|
|
121
|
+
return found.size === 1 ? found.values().next().value : undefined;
|
|
132
122
|
}
|
|
133
123
|
/**
|
|
134
|
-
* The
|
|
124
|
+
* The attribute a reference reads off the resource behind it.
|
|
135
125
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
126
|
+
* A reference naming a resource address and nothing else names no attribute,
|
|
127
|
+
* and is the resource itself. A reference through a module output names the
|
|
128
|
+
* output rather than the attribute, and the output's own expression says
|
|
129
|
+
* which attribute that is.
|
|
139
130
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (qualified !== address && !qualified.startsWith(`${address}.`)) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (best === undefined || address.length > best.address.length) {
|
|
147
|
-
best = resource;
|
|
148
|
-
}
|
|
131
|
+
attributeName(qualified, address) {
|
|
132
|
+
if (qualified === address) {
|
|
133
|
+
return undefined;
|
|
149
134
|
}
|
|
150
|
-
return
|
|
135
|
+
return qualified.startsWith(`${address}.`)
|
|
136
|
+
? qualified.slice(address.length + 1)
|
|
137
|
+
: this.moduleOutputs.attributeOf(qualified);
|
|
138
|
+
}
|
|
139
|
+
target(qualified) {
|
|
140
|
+
return (this.resources.longestMatch(qualified) ??
|
|
141
|
+
this.moduleOutputs.target(qualified));
|
|
151
142
|
}
|
|
152
143
|
}
|
|
153
144
|
//# sourceMappingURL=sim-tf-reference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-tf-reference.js","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sim-tf-reference.js","sourceRoot":"","sources":["../../src/terraform/sim-tf-reference.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,2EAA2E;AAC3E,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,0BAA0B;IACpB,SAAS,CAA6B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(resource, key, resolver) {
|
|
|
30
30
|
}
|
|
31
31
|
const references = longestFirst(expression.references ?? []);
|
|
32
32
|
for (const reference of references) {
|
|
33
|
-
const address = resolver.targetAddress(reference, resource
|
|
33
|
+
const address = resolver.targetAddress(reference, resource);
|
|
34
34
|
if (address !== undefined) {
|
|
35
35
|
return address;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-tf-referenced.js","sourceRoot":"","sources":["../../src/terraform/sim-tf-referenced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAAkD;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAA2B,EAC3B,GAAW,EACX,QAAoC;IAEpC,MAAM,OAAO,GAAG,0BAA0B,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAEpE,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,0BAA0B,CACxC,QAA2B,EAC3B,GAAW,EACX,QAAoC;IAEpC,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAC5B,UAAkC,CAAC,UAAU,IAAI,EAAE,CACrD,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,
|
|
1
|
+
{"version":3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