Skip to content

feat(aws): isolate OpenCode US Ergo inference identity - #61

Merged
xnoto merged 2 commits into
mainfrom
opencode-ergo-bedrock-identity
Dec 2, 2026
Merged

xnoto merged 2 commits into
mainfrom
opencode-ergo-bedrock-identity

Conversation

@xnoto

@xnoto xnoto commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Prepare a dedicated, initially keyless IAM user for the separately credentialed OpenCode pilot. Grant only streaming and non-streaming Bedrock invocation for the US Ergo profile in us-west-2 and its Ohio backing model when authorized through that profile. Scope follows the AWS model card and profile IAM prerequisites.

Type of change

  • Infrastructure (OpenTofu root or module)

Validation

  • Required pull-request checks pass
  • Generated README refreshed by the canonical pre-commit automation

Static diff and IAM scope reviewed. PR CI is authoritative; expect two additions (IAM user and its inline policy), without unrelated changes or deletes. No live tests in this PR.

Impact and rollout

No existing AWS MCP or OpenCode runtime changes. After a separately approved merge and environment-gated apply, key issuance, encrypted delivery, chart wiring and GitOps enablement are separate steps. No key in Terraform. Before activation, verify successful US Ergo inference and denial for unrelated profiles/direct invocation. Roll back an eventual activation by disabling the provider and revoking its dedicated credential before removing the identity.

Safety and secrets

  • Contains no plaintext secrets, decrypted SOPS values, state files, kubeconfigs, tokens, or private endpoints
  • No local OpenTofu init/plan/apply/destroy/import/state operations were run or claimed — plans come from pull-request checks

AI-authored; independently reviewed for code and infrastructure security.

@xnoto
xnoto requested a review from a team as a code owner December 2, 2026 00:14
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

OpenTofu Test

OpenTofu test passed.

View the workflow run.

View run output
Terraform validate.......................................................Passed
Terraform validate with tflint...........................................Passed
Checkov..................................................................Passed
Terraform fmt............................................................Passed
Terraform docs...........................................................Passed
Detect hardcoded secrets.................................................Passed
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
check for broken symlinks............................(no files to check)Skipped
check vcs permalinks.....................................................Passed
detect destroyed symlinks................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
mixed line ending........................................................Passed
trim trailing whitespace.................................................Passed
don't commit to branch..................................................Skipped
check for added large files..............................................Passed

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

OpenTofu Plan

OpenTofu plan passed.

View the workflow run.

View run output
OpenTofu will perform the following actions:

  # aws_iam_user.opencode_ergo will be created
  + resource "aws_iam_user" "opencode_ergo" {
      + arn           = (known after apply)
      + force_destroy = false
      + id            = (known after apply)
      + name          = "opencode-ergo"
      + path          = "/"
      + tags          = {
          + "ManagedBy" = "Terraform"
          + "Purpose"   = "opencode-ergo-inference"
        }
      + tags_all      = {
          + "ManagedBy" = "Terraform"
          + "Purpose"   = "opencode-ergo-inference"
        }
      + unique_id     = (known after apply)
    }

  # aws_iam_user_policy.opencode_ergo will be created
  + resource "aws_iam_user_policy" "opencode_ergo" {
      + id          = (known after apply)
      + name        = "opencode-ergo-us-inference"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "bedrock:InvokeModel",
                          + "bedrock:InvokeModelWithResponseStream",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:bedrock:us-west-2:332355796717:inference-profile/us.amazon.ergo-1.0"
                      + Sid      = "InvokeUsErgoProfile"
                    },
                  + {
                      + Action    = [
                          + "bedrock:InvokeModel",
                          + "bedrock:InvokeModelWithResponseStream",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "bedrock:InferenceProfileArn" = "arn:aws:bedrock:us-west-2:332355796717:inference-profile/us.amazon.ergo-1.0"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "arn:aws:bedrock:us-east-2::foundation-model/amazon.ergo-1.0"
                      + Sid       = "AllowErgoDestinationOnlyThroughProfile"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + user        = "opencode-ergo"
    }

Plan: 2 to add, 0 to change, 0 to destroy.
OpenTofu will perform the following actions:

  # aws_iam_user.opencode_ergo will be created
  + resource "aws_iam_user" "opencode_ergo" {
      + arn           = (known after apply)
      + force_destroy = false
      + id            = (known after apply)
      + name          = "opencode-ergo"
      + path          = "/"
      + tags          = {
          + "ManagedBy" = "Terraform"
          + "Purpose"   = "opencode-ergo-inference"
        }
      + tags_all      = {
          + "ManagedBy" = "Terraform"
          + "Purpose"   = "opencode-ergo-inference"
        }
      + unique_id     = (known after apply)
    }

  # aws_iam_user_policy.opencode_ergo will be created
  + resource "aws_iam_user_policy" "opencode_ergo" {
      + id          = (known after apply)
      + name        = "opencode-ergo-us-inference"
      + name_prefix = (known after apply)
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action   = [
                          + "bedrock:InvokeModel",
                          + "bedrock:InvokeModelWithResponseStream",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:bedrock:us-west-2:332355796717:inference-profile/us.amazon.ergo-1.0"
                      + Sid      = "InvokeUsErgoProfile"
                    },
                  + {
                      + Action    = [
                          + "bedrock:InvokeModel",
                          + "bedrock:InvokeModelWithResponseStream",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "bedrock:InferenceProfileArn" = "arn:aws:bedrock:us-west-2:332355796717:inference-profile/us.amazon.ergo-1.0"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "arn:aws:bedrock:us-east-2::foundation-model/amazon.ergo-1.0"
                      + Sid       = "AllowErgoDestinationOnlyThroughProfile"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + user        = "opencode-ergo"
    }

Plan: 2 to add, 0 to change, 0 to destroy.

@xnoto
xnoto merged commit 36b071c into main Dec 2, 2026
3 checks passed
@xnoto
xnoto deleted the opencode-ergo-bedrock-identity branch December 2, 2026 00:19
xnoto added a commit to makeitworkcloud/kustomize-cluster that referenced this pull request Dec 2, 2026
## Summary

Stage the operator-supplied SOPS Secret for the dedicated US Ergo
identity from makeitworkcloud/tfroot-aws#61. Add the manifest and
register it with the existing OpenCode KSOPS generator. This draft does
not change the chart, deployment settings, or model availability.

## Type of change

- [x] GitOps desired state (manifests, kustomize, charts, SOPS/KSOPS
secrets)

## Validation

- [x] Required pull-request checks pass
- [x] Authorized operator reports the KSOPS validation passed for the
proposed change (operator attestation; not independently rerun).

PR CI cannot decrypt the full KSOPS overlay; green CI is not proof of
decryptability or manifest correctness. The operator confirmed both
expected fields have SOPS encryption markers. GitHub blob metadata
confirms the manifest is unchanged from the operator-checked revision.
The manifest contents were not independently reviewed.

## Impact and rollout

Opening this PR did not deploy. After validation and separate explicit
merge approval, Argo CD can reconcile the Secret in the OpenCode
namespace. Verify the merged revision, Secret metadata, and application
health. Chart wiring, provider enablement, and inference checks remain
separate. If the registration fails to reconcile, use a reviewed GitOps
revert; do not alter live state manually.

## Safety and secrets

- [ ] Authorized reviewer confirms the manifest has no plaintext
credentials or other prohibited material
- [x] No local OpenTofu operations were run

AI-assisted generator wiring and PR preparation. Do not include
credential material in review notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant