You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/internal/compute-provider-refactor.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,26 +22,27 @@ The implementation is split into orchestration, provider-neutral control-plane c
22
22
|`runner-stack/pool`| Optional scheduled runner-pool resources and their Lambda and IAM wiring. |
23
23
|`runner-stack/job-retry`| Optional queued-job retry resources and their Lambda and IAM wiring. |
24
24
|`runner-stack/ssm-housekeeper`| Parameter Store cleanup Lambda, schedule, logging, and IAM resources. |
25
-
|`compute-providers/<provider>`| Provider-specific resources, runner-role trust and permission requirements, and the IAM and environment-variable fragments consumed by the common control plane. |
25
+
|`compute-providers/<provider>/trust-policy`| Provider-specific default runner-role trust, merged with the optional caller-provided trust document before the common role is created. |
26
+
|`compute-providers/<provider>`| Provider-specific resources, permission requirements, and the IAM and environment-variable fragments consumed by the common control plane after the runner role is resolved. |
26
27
27
28
The EC2 provider owns the instance profile, launch template, security group, AMI and bootstrap parameters, runner log groups, EC2 policy statements, and EC2 Lambda environment variables. The MicroVM provider owns the Lambda MicroVM runtime configuration, execution-role policy, and MicroVM Lambda environment variables. Terraform does not manage MicroVM lifecycle resources directly; the runtime control plane creates and terminates MicroVM runners.
28
29
29
30
The modules below `runner-stack` are internal implementation boundaries, not standalone public modules. Callers opt into the experimental interface through `experimental.multi_runner_config_v2`; `multi-runner` calls `runner-stack`, which composes the internal modules. Their direct input and output contracts may change while v2 remains experimental.
30
31
31
32
`runner-stack` selects a compute provider from the single populated typed block under `compute_provider`. For example, `compute_provider = { ec2 = { ... } }` selects EC2 and `compute_provider = { microvm = { ... } }` selects MicroVM; there is no separate `type` input that can disagree with the populated block. Exactly one provider block must be populated, and its presence must be known during planning because it determines the module graph. Native input validation enforces this common selection rule, while each compute-provider module owns its provider-specific semantic validation. The stack passes `compute_provider.<provider>` to the selected provider module as one nested `config` object. It also passes the provider-neutral `runner`, `github`, `ssm`, and `observability` objects without expanding them back into prefixed scalar inputs. This keeps ownership visible at the module boundary and gives future compute providers an equivalent contract to implement.
32
33
33
-
The common stack creates or selects the runner IAM role, but the selected provider owns the role's trust-policy document. Each provider exposes that document through a dedicated `assume_role_policy` output and separately returns its nested `provider` contract containing `policies.runner`, `policies.scale_up`, `policies.scale_down`, and `policies.pool`, component environment variables, and provider resources. The common stack uses the trust document when it creates the runner role and attaches the returned permission documents to the roles owned by the corresponding common components. A provider never creates or attaches a common IAM role.
34
+
The common stack creates or selects the runner IAM role, but the selected provider owns the role's default trust-policy document. Each provider implements a small `trust-policy` submodule that accepts `additional_trust_policy_json` and returns the final `assume_role_policy`. The full provider separately returns its nested `provider` contract containing `policies.runner`, `policies.scale_up`, `policies.scale_down`, and `policies.pool`, component environment variables, and provider resources. The common stack uses the isolated trust-policy output when it creates the runner role and attaches the full provider's permission documents to the roles owned by the corresponding common components. A provider never creates or attaches a common IAM role.
34
35
35
-
The trust relationship is deliberately rendered by a dedicated file and output inside each compute-provider module:
36
+
The trust relationship is deliberately rendered by an isolated provider submodule:
36
37
37
38
1.`runner-stack` selects the provider from the populated typed block.
38
-
2.`compute-providers/<provider>/assume-role.tf` renders the provider-specific policy without referencing the runner-role input.
39
-
3.`runner-stack` creates or selects the common runner role from that policy.
39
+
2.`compute-providers/<provider>/trust-policy` combines the provider default with `runner.iam.additional_trust_policy_json` without referencing the runner-role input.
40
+
3.`runner-stack` creates or selects the common runner role from the returned `assume_role_policy`.
40
41
4. The full compute provider receives the resolved role so it can create resources such as the EC2 instance profile and render `iam:PassRole` statements.
41
42
5. The provider returns its nested policy, environment-variable, and resource contract.
42
43
6. The common components attach the returned policies to the runner, scale-up, scale-down, and pool roles they own.
43
44
44
-
The dedicated `assume_role_policy`output depends only on the provider's trust document, not on resources that consume the runner role. `runner-stack` accesses the selected counted module through a direct `[0]` reference so Terraform preserves that output-level dependency; a full splat would add the module-close dependency and recreate the role cycle. This preserves provider ownership of the trust relationship while keeping the dependency graph one-way.
45
+
The trust-policy output depends only on its input documents, not on the full provider resources that consume the runner role. This preserves provider ownership of the trust relationship while keeping the dependency graph one-way.
Copy file name to clipboardExpand all lines: modules/compute-providers/ec2/README.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,6 @@ No modules.
43
43
|[aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami)| data source |
44
44
|[aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity)| data source |
45
45
|[aws_iam_policy_document.ami_id_ssm_parameter_read](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
46
-
|[aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
47
46
|[aws_iam_policy_document.cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
48
47
|[aws_iam_policy_document.create_tags](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
49
48
|[aws_iam_policy_document.describe_tags](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
@@ -78,5 +77,4 @@ No modules.
78
77
| <aname="output_policies"></a> [policies](#output\_policies)| Provider-specific IAM policy fragments consumed by runner-stack. |
This internal submodule builds the EC2 runner-role trust policy independently from EC2 resources that consume the runner role. It preserves the default EC2 service trust and optionally merges an additional IAM trust policy document supplied by the common runner stack.
|[aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
28
+
|[aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
29
+
30
+
## Inputs
31
+
32
+
| Name | Description | Type | Default | Required |
| <aname="input_additional_trust_policy_json"></a> [additional\_trust\_policy\_json](#input\_additional\_trust\_policy\_json)| Optional IAM policy document merged with the default EC2 runner-role trust policy. |`string`|`null`| no |
35
+
36
+
## Outputs
37
+
38
+
| Name | Description |
39
+
|------|-------------|
40
+
| <aname="output_assume_role_policy"></a> [assume\_role\_policy](#output\_assume\_role\_policy)| EC2 runner-role trust policy with the optional additional trust policy merged into it. |
0 commit comments