
Summary
Key points of this document
- When the foundation changes, dependent designs cascade.
- Three Boundaries to Confirm
- Create an Ownership Matrix First
Overview
Customer Account or Our Own Account — A Design Contract to Define "Infrastructure Ownership Boundaries" Before Letting AI Write Code
"Should this feature be built within the customer's AWS/GCP account? Or our own account?"
Suppose this question wasn't confirmed before letting AI create an upload function or a nightly batch job. In the development company's existing environment, saving, external API calls, and scheduled executions all work smoothly. However, when considering migration to the customer's environment, the available IAM permissions and SCPs, external SaaS contracts and billing, private VPCs and ECS, and connections to on-premises systems differ from the assumptions. Databases, object storage, and encryption keys cannot simply be moved by changing connection destinations; redesign and re-verification become necessary.
The "boundary contract" in this article is a design artifact approved by stakeholders that constrains implementation, and does not refer to a legal contract itself. The term "account" here does not mean a user ID for logging into an application. It refers to the boundary of who owns management units like AWS, Google Cloud, and Cloudflare, who bears the costs, and who can modify, audit, or terminate them. Technical affiliation verifiable via API and contractual entities must be confirmed separately. AI tends to fill in unstated assumptions with existing configurations that work locally. As a result, the higher the functional completeness, the harder it becomes to see the cost of changing boundaries later.
When the foundation changes, dependent designs cascade.
The following arrows indicate that upstream conditions constrain downstream choices. Not every change breaks all code. Design changes and re-verification cascade in areas tied to the migration destination's conditions. For example, in Google Cloud project migration, while resources and settings may be preserved, it's necessary to check the impact of inherited IAM and organization policies at the destination. Google Cloud: Project Migration
For example, an API callable from your company's public network may not be usable from a customer's private environment. SCPs are mechanisms to control the upper limit of permissions and do not grant permissions themselves. Necessary permissions must be evaluated separately. AWS Organizations: SCP Also, using a KMS key from another account requires both the key policy on the key side and the IAM policy on the caller side. AWS KMS: Cross-account access
When migrating authentication infrastructure, the issuer, audience, callback URL, and DNS change, which can affect token validation and login paths. Encrypted RDS snapshots, if encrypted with AWS-managed keys, cannot be shared directly, so a separate migration procedure must be designed. RDS: Sharing an encrypted snapshot
The direction of dependency is not one-way. If contracts or private network requirements are decided first, the available execution methods are narrowed down. Conversely, if necessary external integrations for business operations are identified, network and contract agreements are re-evaluated. The important thing is not to finalize unapproved assumptions for the sake of implementation convenience.
Three Boundaries to Confirm
- Compute and Data: Who manages the execution environment, data storage, backups, keys, and network? This includes data location, export, restoration, and deletion.
- SaaS Contracts and Billing: For external services like email delivery, maps, and AI, confirm the contracting party, user entity, billing recipient, issued credentials, usage restrictions, and handling upon contract termination. Issuing a dedicated key does not necessarily mean the contract has been transferred; contracts, organizations/tenants/projects, billing, identity verification, and data export must be confirmed individually. Do not proceed with development or transmission of actual data using your company's common key just because customer contract preparation is delayed. An API success does not guarantee the billing destination is correct.
- Operations and Audit: Who can perform deployment, incident response, log viewing, permission granting/revocation, audit trails, and recovery after maintenance ends? Record owners and operational contractors separately.
The names of management units vary by cloud provider. In Google Cloud, the hierarchy of organizations, folders, and projects, and the billing accounts associated with projects, are confirmed separately. Google Cloud: Resource hierarchy and billing In Cloudflare, accounts and zones are treated as separate scopes, and management permissions for zones are also confirmed. Cloudflare: Accounts and zones
Create an Ownership Matrix First
The following is an example where ECS, RDS, and S3 are operated within a customer's AWS account, and the development company is delegated permissions. This is not the correct answer for a real project. Account IDs, resource names, and contract details are all fictitious; replace each field with mutually approved facts. While an account ID itself is not authentication information, actual customer IDs should not be disclosed, and fictitious values should be used.
"Customer Owned" in the table does not mean the development company cannot operate it. Permissions can be delegated cross-account with defined terms, scope, and audit. Conversely, a configuration where the company owns the infrastructure as its own SaaS and provides usage rights to customers is also possible. Explicit agreement on costs, data processing, availability, and handover upon exit is a prerequisite.
Boundary Contract: Defined by Humans, Handed to AI
Before code generation, the customer's responsible person and the design lead approve ownership, operations, billing, and constraints, with version control for each environment. The example below is fictitious and shows the structure; this excerpt alone is not a contract ready for production deployment.
version: 1
status: approved
runtime:
owner: customer
aws_account_id: "123456789012" # Fictitious
execution: ecs
operator: delegated_developer
network: customer_private_vpc
data:
database_owner: customer
object_storage_owner: customer
kms_key_owner: customer
external_service:
contract_and_billing: customer
credential_issuer: customer
change_control:
boundary_change: human_approval_required
unresolved: block_dependent_workIn practice, the target environment, region, specific approved resources, roles, communication destinations, log storage locations, verification methods, approvers, deadlines, and exit conditions are also documented. Sensitive values are not included in the contract. unresolved should not be filled with existing company settings; it should halt dependent implementations, real data connections, and deployments. Pure business rules and mock-based tests that do not depend on boundaries can proceed in parallel. The contract is input to the AI, and when changes to ownership, SaaS, communication paths, permissions, keys, or billing become necessary, the AI stops and presents the differences and impacts to a human. After approval, the contract and tests are updated, and implementation resumes.
Verify Contracts with Machines
IaC and Execution Principal
Terraform's AWS provider can detect errors in authenticated accounts using allowed_account_ids. The IDs below are fictitious. When using multiple provider aliases, specify approved IDs corresponding to all configurations. Terraform AWS provider
provider "aws" {
region = "ap-northeast-1"
allowed_account_ids = ["123456789012"]
}This is not a universal ownership check. Terraform's S3 backend authenticates independently of the provider, so the state storage location/access rights and the backend's own allowed_account_ids are configured separately. If the design uses different accounts for the backend and resources, specify approved values for each. Since state can contain sensitive information, design encryption, access restrictions, locking, version control, and recovery. Terraform S3 backend In CI, after assuming the intended role with OIDC, confirm the actual authentication principal before planning and applying. Pulumi's AWS classic Provider also has allowedAccountIds (notation varies by language); specify it according to the provider and language specifications used. Pulumi AWS Provider CloudFormation does not assume an attribute of the same name; the caller, target stack, and target accounts for StackSets are verified separately.
Correlate with Runtime Measurements
While it's useful to validate required items and formats of environment variables with tools like Zod, comparing environment variables against each other won't detect errors if both are incorrect. Zod: Schema Validation Approved contracts should be obtained from a trusted distribution channel that cannot be freely changed simultaneously with app settings. At startup, the following should be cross-referenced, and if they don't match or cannot be obtained, the process should stop before DB connection, data processing, external transmission, or readiness exposure.
- Correlate the Account and Arn from AWS STS
GetCallerIdentitywith the execution principal approved for the environment. AWS STS API - For connection destinations, not only configuration strings but also actual resource identifiers, owner accounts, regions, and necessary encryption keys should be obtained from each service's management API, etc., and cross-referenced with the contract. For resources like S3 where the ARN does not include an account ID, a separate owner verification appropriate for the target service should be performed. For example, S3's
HeadBucketallows specifying an expected owner. However, a 403 error can also occur due to other permission deficiencies, so it should not be definitively concluded as an owner mismatch. S3 HeadBucket - For SaaS, independent evidence appropriate to the service, such as contract/tenant information from the management API or signed certificates verifiable by issuer and expiration date, should be cross-referenced. If the billing entity cannot be verified via API, manual confirmation of the billing screen and contract acceptance is mandatory.
STS indicates the caller and does not prove the resource owner in another account or the billing destination for SaaS. Do not falsely claim that items for which there is no means of proof could be automatically verified at startup. Audit logs should retain verification results and contract versions, and secret values should not be output. Accept the availability impact of being unable to start due to temporary external API failures, and prepare monitoring and recovery procedures.
In CI, we statically detect the inclusion of internal endpoints, unauthorized IDs, and secret references. However, string searches can miss dynamically generated or aliased items. We combine IaC plan and policy checks, network destination restrictions, and secret scanning to complement real-world verification.
Negative testing and customer-centric acceptance
Just "working with the correct settings" doesn't guarantee boundary protection. At a minimum, try the following and confirm that no data is saved or externally transmitted upon failure.
- Provide credentials for a different account, an unauthorized provider alias, or an incorrect backend, and stop before plan or apply.
- Specify storage or keys of a different owner from the correct execution role, and stop at real resource verification. Also verify SCP/key permission deficiencies and inability to communicate from a private network.
- Provide an incorrect SaaS tenant, expired credentials, unconfirmed billing entity, or inability to obtain a verification API, and do not transmit until agreed-upon verification is complete.
- The customer performs deployment, log viewing, secret information updates, backup restoration, and re-execution during failures themselves. Confirm the customer's operational continuity and audit trails with the development company's delegation revoked.
- At termination, confirm data return/retention/deletion, key and credential revocation, and handover of DNS, certificates, state, and CI in accordance with the agreement.
AI increases the speed of writing code. However, if it's undecided whose land a house is built on, discussions about relocating an entire completed mansion will be repeated later. The design to prevent speed from turning into rework is to first define the boundaries of ownership and operation as a contract, and then uphold that contract in both implementation and verification.
codex Finished independent review of the draft, correcting when Terraform rejects incorrect accounts and the scope of SCP application. Additionally, specific role acquisition methods, secret information sources, and monitoring destinations have been added to the ownership matrix, making it ready for design review. collab: Wait exec /bin/bash -lc 'cat /tmp/infra-ownership-contract-draft.md' in /mnt/ssd1tb/development/repos/flares.jp2026 succeeded in 0ms:
Customer account or company account? — A design contract to define "infrastructure ownership boundaries" before letting AI write code.
"Should this feature be built within the customer's AWS/GCP account? Or our own company's account?"
Our readily available company repository contains familiar SDKs, methods for obtaining Secrets, and settings for running on Edge. If we ask AI to create an upload function and a nightly batch using these as examples, it quickly passes functional tests, including saving and external transmission. But what happens if we only then realize it was supposed to be delivered to a "customer account"?
This is a hypothetical example, but simply replacing the storage destination or credentials may not be enough. It's necessary to identify each assumption of the running code and cross-reference it with conditions the customer can permit.
- IAM/SCP: Are storage, processing, and auditing permitted under the customer's permission limits and execution roles?
- SaaS: Who holds the contracts, billing, and credentials for email, OpenAI API, payment, Sentry, and authentication?
- Execution location: When moved from our company's Edge to the customer's private VPC/ECS, can communication paths and scheduled executions be maintained?
- Data: How to handle DB and storage migration, backups, customer-managed KMS keys, and restoration permissions.
The "boundary contract" in this paper is a design artifact approved by stakeholders that binds implementation, and does not refer to a legal contract itself. The "account" here does not mean a user ID for logging into an application. It refers to the boundary of who owns the management units like AWS, Google Cloud, and Cloudflare, who bears the costs, and who can make changes, audit, and terminate. Technical affiliation verifiable by API and contractual entities are confirmed separately. AI tends to fill in unstated assumptions with existing configurations that run locally. As a result, the higher the functional completeness, the less visible the cost of changing boundaries later becomes.
When the foundation changes, dependent designs cascade.
The following arrow indicates that upstream conditions constrain downstream choices. This does not mean every change breaks all code. Design changes and re-verification cascade in areas linked to the transfer destination's conditions. For example, in Google Cloud project migration, while resources and settings may be maintained, it's necessary to confirm the impact of inherited IAM and organizational policies at the transfer destination. Google Cloud: Project Migration
For example, an API callable from our company's public network may not be usable from a customer's private environment. SCP is a mechanism to control the upper limit of permissions, and it does not grant permissions itself. Since it does not apply to users or roles in the management account, the execution principal, scope of application, and necessary permissions must be evaluated separately. AWS Organizations: SCP Also, using a KMS key from another account requires both the key policy on the key side and the IAM policy on the caller side. AWS KMS: Cross-account access
When migrating authentication infrastructure, the issuer, audience, callback destination, and DNS change, which can affect token validation and login paths. Encrypted RDS snapshots, if encrypted with AWS-managed keys, cannot be shared directly, so a separate migration procedure must be designed. RDS: Sharing an encrypted snapshot
The direction of dependency is not one-way. If contract or private network requirements are decided first, the available execution methods are narrowed down. Conversely, if externally required business collaborations are identified, network and contract agreements are re-evaluated. The important thing is not to finalize unapproved assumptions for implementation convenience.
Three boundaries to confirm
- Compute and Data: Who manages the execution environment, data storage, backups, keys, and network? This includes data location, export, restoration, and deletion.
- SaaS Contracts and Billing: For external services like email delivery, maps, and AI, confirm the contractor, user entity, billing recipient, issued credentials, usage restrictions, and handling at contract termination. Issuing a dedicated key does not necessarily mean the contract has been transferred; contracts, organizations/tenants/projects, billing, identity verification, and data export must be confirmed individually. Do not proceed with real data development or transmission using the company's common key due to delays in customer contract preparation. An API success does not always mean the billing destination is correct.
- Operations and Auditing: Who can perform deployment, incident response, log viewing, permission granting/revocation, audit trails, and recovery after maintenance ends? Record owners and operational contractors separately.
The names of management units differ by cloud. In Google Cloud, the hierarchy of organizations, folders, and projects, and the billing accounts associated with projects are confirmed separately. Google Cloud: Resource Hierarchy and Billing In Cloudflare, accounts and zones are treated as separate scopes, and management permissions for zones are also confirmed. Cloudflare: Accounts and Zones
Create the ownership matrix first
The following is an example where ECS, RDS, and S3 are operated within a customer's AWS account, and the development company is delegated permissions. This is not the correct answer for a real project. Account IDs, resource names, and contract details are all fictitious; replace each field with mutually approved facts. While an account ID itself is not a credential, actual customer IDs should not be disclosed, and fictitious values should be used.
"Customer Owned" in the table does not mean the development company cannot operate it. Permissions can be delegated cross-account with defined terms, scope, and auditing. Conversely, a configuration where the company owns the infrastructure as its own SaaS and provides usage rights to the customer is also possible. This requires explicit agreement on costs, data processing, availability, and handover upon exit.
Boundary contract decided by humans and handed over to AI
Before code generation, the customer's responsible person and design lead approve ownership, operation, billing, and constraints, and manage versions for each environment. The example below is fictitious, showing the structure, and is not a contract ready for production deployment based on this excerpt alone.
version: 1
status: approved
environment: production
provider: aws
region: ap-northeast-1
account_id: "123456789012" # All IDs and names below are fictitious.
deploy:
role_arn: "arn:aws:iam::123456789012:role/example-deploy"
credential_source: ci_oidc
runtime:
owner: customer
execution: ecs
role_arn: "arn:aws:iam::123456789012:role/example-task"
credential_source: ecs_task_role
operator: delegated_developer
network: customer_private_vpc
data:
bucket: example-customer-bucket
bucket_owner_account_id: "123456789012"
kms_key_arn: "arn:aws:kms:ap-northeast-1:123456789012:key/00000000-0000-0000-0000-000000000000"
external_service:
contract_and_billing: customer
organization_id: example-org
tenant_id: example-tenant
secret_source_arn: "arn:aws:secretsmanager:ap-northeast-1:123456789012:secret:example-credential-ABC123"
change_control:
boundary_change: human_approval_required
unresolved: block_dependent_workIn practice, the target environment, region, specific approved resources, roles, communication destinations, log storage locations, verification methods, approvers, deadlines, and exit conditions are also described. Sensitive values are not included in the contract. unresolved should not be filled with existing company settings; it should halt dependent implementations, real data connections, and deployments. Pure business rules and mock-based tests that do not depend on boundaries can proceed in parallel. The contract is input to the AI, and when there is a need to change ownership, SaaS, communication paths, permissions, keys, or billing, the AI should stop and present the differences and impacts to a human. After approval, the contract and tests are updated, and implementation resumes.
Verify contracts with machines
IaC and execution principal
Terraform's AWS provider can detect errors in authenticated accounts using allowed_account_ids. The IDs below are fictitious. If multiple provider aliases are used, specify approved IDs corresponding to all configurations. Terraform AWS provider
provider "aws" {
region = "ap-northeast-1"
allowed_account_ids = ["123456789012"]
}This is not a universal ownership check. Terraform's S3 backend authenticates independently of the provider, so the state's storage destination/access rights and the backend's own allowed_account_ids are configured separately. If the design uses different accounts for the backend and resources, specify approved values for each. Since state can contain sensitive information, design encryption, access restrictions, locking, version control, and recovery. Terraform S3 backend In CI, after assuming the intended role with OIDC, confirm the actual authentication principal before plan/apply. Pulumi's AWS classic Provider also has allowedAccountIds (notation varies by language), which should be specified according to the provider and language specifications used. Pulumi AWS Provider CloudFormation does not assume attributes of the same name; instead, it separately verifies the caller, target stack, and target accounts for StackSets.
Cross-reference with actual measurements at startup
While it's useful to validate required items and formats of environment variables with tools like Zod, comparing environment variables against each other won't detect errors if both are incorrect. Zod: Schema Validation Approved contracts are obtained from trusted distribution channels that cannot be freely changed simultaneously with app settings. At startup, the following are verified, and if they don't match or cannot be obtained, the system halts before DB connection, data processing, external transmission, or readiness exposure.
- Match the Account and Arn from AWS STS
GetCallerIdentityagainst the execution principal approved for the environment. AWS STS API - The connection destination is verified against the contract by obtaining the actual resource identifier, owner account, region, and necessary encryption keys from the management API of each service, not just from configuration strings. For resources like S3 where the ARN does not include an account ID, a separate owner verification appropriate for the target service is performed. For example, S3's
HeadBucketallows specifying an expected owner. However, a 403 error can also occur due to other permission deficiencies, so it should not be definitively concluded as an owner mismatch. S3 HeadBucket - SaaS verifies independent evidence appropriate for the service, such as contract/tenant information from the management API, or signed certificates whose issuer and expiration date can be validated. If the billing entity cannot be verified via API, manual confirmation of the billing screen and contract acceptance is required.
The following is an outline of pre-startup checks. loadApprovedContract returns an independently distributed contract with verified signature and version. verifySaaS is a dedicated adapter that matches contracts with organizations/tenants from read-only management APIs or certificates with verified signatures, issuers, and expiration dates, throwing an exception if verification fails. Both require implementation, and environment variables should not be used in place of actual measured values.
import { z } from "zod";
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
import { S3Client, HeadBucketCommand } from "@aws-sdk/client-s3";
try {
const env = z.object({ AWS_REGION: z.string().min(1) }).parse(process.env);
const contract = await loadApprovedContract(); // Independently distributed and signature verified
if (env.AWS_REGION !== contract.region) throw new Error("region mismatch");
const identity = await new STSClient({ region: contract.region })
.send(new GetCallerIdentityCommand({}));
if (identity.Account !== contract.accountId) throw new Error("account mismatch");
await new S3Client({ region: contract.region }).send(new HeadBucketCommand({
Bucket: contract.bucket,
ExpectedBucketOwner: contract.bucketOwnerAccountId,
}));
await verifySaaS(contract.saas); // Reconcile verified actual measurements with approved contract
await startApplication(); // DB connection and readiness exposure after inspection
} catch {
console.error("boundary verification failed"); // Do not expose secret values or exception details
process.exit(1);
}This excerpt omits verification of execution roles, KMS, DB, network constraints, and billing entities. HeadBucket requires necessary permissions and reachability from a private network. There are also configurations where, instead of granting SaaS administrator keys or broad AWS Describe/List permissions to runtime solely for ownership verification, measurements are taken by CI or a dedicated pre-validation role, and a certificate bundling signature, expiration date, and target revision is verified at startup. In production, considering that the contract's IAM role ARN and STS's assumed-role ARN have different formats, roles are verified using a reliable method. HeadBucket confirms bucket ownership and does not prove ownership or configuration of KMS keys or databases. These are separately verified via their respective management APIs.
STS indicates the caller and does not prove resource ownership in other accounts or SaaS billing destinations. Do not falsely claim that items for which there is no means of obtaining proof were automatically verified at startup. Audit logs should retain verification results and contract versions, and secret values should not be output. Accept the availability impact of being unable to start due to temporary external API failures, and prepare monitoring and recovery procedures.
CI also statically detects the inclusion of internal endpoints, unauthorized IDs, and secret information references. However, string searches can miss dynamically generated or aliased items. Combine IaC plan and policy checks, network destination restrictions, and secret scans to complement real-environment verification.
Negative cases and customer-driven acceptance
Just 'working with correct settings' doesn't guarantee boundary protection. At a minimum, try the following and confirm that no data is saved or externally transmitted upon failure.
- Provide credentials for a different account, and ensure CI's execution principal verification stops before the plan phase. Also, try unauthorized provider aliases or incorrect backends, and confirm that IaC guards terminate with an error at the corresponding init, plan, or apply stage, preventing progression to production changes. Protect backend initialization and state migration as separate stages.
- Specify storage or keys belonging to a different owner from the correct execution role, and ensure it stops at actual resource verification. Also, verify SCP/key permission deficiencies and inability to communicate from a private network.
- Provide incorrect SaaS tenants, expired credentials, unverified billing entities, or inability to obtain proof from the API, and do not transmit until agreed-upon verification is complete.
- The customer independently performs deployment, log viewing, secret information updates, backup restoration, and re-execution during failures. Confirm the customer's operational continuity and audit trails with the development company's delegation revoked.
- Upon termination, confirm data return/retention/deletion, key and credential revocation, and handover of DNS, certificates, state, and CI in accordance with the agreement.
AI increases the speed of writing code. However, if the question of whose land to build on remains undecided, discussions about relocating an entire completed mansion later will recur. The design to prevent speed from turning into rework is to first establish the boundaries of ownership and operation as a contract, and then uphold that contract in both implementation and verification.
codex The final check also closes the loophole where 'the inspected connection destination differs from the one the app actually uses.' We've used an example where verified settings and credentials are passed directly to the app, aligning the document's assertion with the code example. exec /bin/bash -lc 'cat /tmp/infra-ownership-contract-draft.md' in /mnt/ssd1tb/development/repos/flares.jp2026 succeeded in 0ms:
Customer account or our own account? — A design contract to define 'infrastructure ownership boundaries' before letting AI write code
'Should this feature be built within the customer's AWS/GCP account? Or our own account?'
Our readily available internal repository contains familiar SDKs, methods for obtaining Secrets, and settings for running on Edge. If we ask AI to build an upload feature and a nightly batch using these as examples, it quickly passes functional tests, including saving and external transmission. But what happens if we only then realize it was supposed to be delivered to a customer account?
Organize rework due to incorrect ownership transfers as design rules to prevent recurrence. The following technical configurations are generalized for explanatory purposes. Simply replacing storage destinations or credentials may not be sufficient. It's necessary to identify each assumption of the running code and cross-reference it with conditions the customer can permit.
- IAM/SCP: Are saving, processing, and auditing permitted under the customer's permission limits and execution roles?
- SaaS: Who holds the contracts, billing, and credentials for email, OpenAI API, payments, Sentry, and authentication?
- Execution location: When moved from our Edge to the customer's private VPC/ECS, can communication paths and scheduled executions be maintained?
- Data: How to handle DB and storage migration, backups, customer-managed KMS keys, and restoration permissions?
The 'boundary contract' in this paper is a design artifact approved by stakeholders that constrains implementation, not a legal contract itself. The term 'account' here does not refer to a user ID for logging into an app. It refers to the boundary of who owns management units like AWS, Google Cloud, and Cloudflare, who bears the costs, and who can make changes, audit, and terminate. Technical affiliation verifiable via API and contractual entities are confirmed separately. AI tends to fill in unstated assumptions with existing configurations that run locally. As a result, the higher the functional completeness, the less visible the cost of changing boundaries later becomes.
When the foundation changes, dependent designs cascade.
The following arrow indicates that upstream conditions constrain downstream choices. This does not mean every change breaks all code. Design changes and re-verification cascade to parts linked to the transfer destination's conditions. For example, in Google Cloud project migration, while resources and settings may be preserved, it's necessary to check the impact of inherited IAM and organizational policies at the destination. Google Cloud: Project Migration
For example, an API callable from our public network may not be usable from a customer's private environment. SCPs are mechanisms to control the upper limits of permissions and do not grant permissions themselves. Since they do not apply to users or roles in the management account, the execution principal, scope of application, and necessary permissions must be evaluated separately. AWS Organizations: SCP Furthermore, using a KMS key in a different account requires both the key policy on the key side and the IAM policy on the caller side. AWS KMS: Cross-account access
When migrating authentication infrastructure, the issuer, audience, callback destination, and DNS change, which can affect token validation and login paths. Encrypted RDS snapshots, if encrypted with AWS-managed keys, cannot be shared directly, so a separate migration procedure must be designed. RDS: Sharing an encrypted snapshot
The direction of dependency is not one-way. If contract and private network requirements are decided first, the available execution methods are narrowed down. Conversely, if externally required business integrations are identified, network and contract agreements are re-evaluated. The important thing is not to finalize unapproved assumptions based on implementation convenience.
Three boundaries to confirm
- Compute and Data: Who manages the execution environment, data storage, backups, keys, and network? This includes data location, export, restoration, and deletion.
- SaaS Contracts and Billing: For external services like email delivery, maps, and AI, confirm the contracting party, user entity, billing destination, issued credentials, usage restrictions, and handling upon contract termination. Issuing a dedicated key does not necessarily mean the contract has been transferred; contracts, organizations/tenants/projects, billing, identity verification, and data export must be confirmed individually. Do not proceed with developing or transmitting actual data using your company's common keys just because customer contract preparation is delayed. Even if an API call succeeds, the billing destination may not be correct.
- Operations and Audit: Who can perform deployment, incident response, log viewing, permission granting/revocation, audit trails, and recovery after maintenance ends? Record owners and operational contractors separately.
The names of management units vary by cloud. In Google Cloud, the hierarchy of organizations, folders, and projects, and the billing accounts associated with projects are confirmed separately. Google Cloud: Resource hierarchy and billing In Cloudflare, accounts and zones are treated as separate scopes, and management permissions for zones are also confirmed. Cloudflare: Accounts and zones
Create an ownership matrix first.
The following is an example where ECS, RDS, and S3 are operated within a customer's AWS account, and the development company is delegated permissions. This is not the definitive answer for actual projects. Account IDs, resource names, and contract details are all fictitious; replace each field with facts approved by both parties. While the account ID itself is not authentication information, actual customer IDs should not be disclosed, and fictitious values should be used.
'Customer Owned' in the table does not mean the development company cannot operate it. Permissions can be delegated cross-account with defined terms, scope, and audit. Conversely, a configuration where the company owns the infrastructure as its own SaaS and provides usage rights to customers is also possible. This requires explicit agreement on costs, data processing, availability, and handover upon exit.
Boundary Contract: Defined by Humans, Handed Over to AI
Before code generation, the customer's responsible person and design lead must approve ownership, operation, billing, and constraints, with version control for each environment. The following is a fictitious example illustrating the structure, and this excerpt alone is not a contract ready for production deployment.
version: 1
status: approved
environment: production
provider: aws
region: ap-northeast-1
account_id: "123456789012" # All IDs and names below are fictitious.
deploy:
role_arn: "arn:aws:iam::123456789012:role/example-deploy"
credential_source: ci_oidc
runtime:
owner: customer
execution: ecs
role_arn: "arn:aws:iam::123456789012:role/example-task"
credential_source: ecs_task_role
operator: delegated_developer
network: customer_private_vpc
data:
bucket: example-customer-bucket
bucket_owner_account_id: "123456789012"
kms_key_arn: "arn:aws:kms:ap-northeast-1:123456789012:key/00000000-0000-0000-0000-000000000000"
external_service:
contract_and_billing: customer
organization_id: example-org
tenant_id: example-tenant
secret_source_arn: "arn:aws:secretsmanager:ap-northeast-1:123456789012:secret:example-credential-ABC123"
change_control:
boundary_change: human_approval_required
unresolved: block_dependent_workIn practice, the target environment, region, specific approved resources, roles, communication destinations, log storage locations, verification methods, approvers, deadlines, and exit conditions are also specified. Sensitive values are not included in the contract. unresolved should not be filled with existing internal settings; it should halt dependent implementations, real data connections, and deployments. Pure business rules and mock-based tests that do not depend on boundaries can proceed in parallel. The contract is input to the AI, and when there is a need to change ownership, SaaS, communication paths, permissions, keys, or billing, the AI stops and presents the differences and impacts to a human. After approval, the contract and tests are updated, and implementation resumes.
Machine Verification of Contracts
IaC and Execution Principal
Terraform's AWS provider can detect errors in authenticated accounts using allowed_account_ids. The IDs below are fictitious. If multiple provider aliases are used, specify approved IDs corresponding to all configurations. Terraform AWS provider
provider "aws" {
region = "ap-northeast-1"
allowed_account_ids = ["123456789012"]
}This is not a universal ownership check. Terraform's S3 backend authenticates independently of the provider, so the state storage location, access rights, and the backend's own allowed_account_ids must be configured separately. If the design uses different accounts for the backend and resources, specify approved values for each. Since state may contain sensitive information, design for encryption, access restrictions, locking, version control, and recovery. Terraform S3 backend In CI, after assuming the intended role with OIDC, confirm the actual authentication principal before plan and apply. Pulumi's AWS classic Provider also has allowedAccountIds (notation varies by language); specify it according to the provider and language specifications used. Pulumi AWS Provider CloudFormation does not assume an attribute of the same name; instead, it separately verifies the caller, target stack, and target accounts for StackSets.
Runtime Measurement and Verification
While it's useful to validate required items and formats of environment variables with tools like Zod, comparing environment variables against each other won't detect errors if both are incorrect. Zod: Schema Validation Approved contracts are obtained from a trusted distribution channel that cannot be freely changed simultaneously with app settings. At startup, the following are verified; if they do not match or cannot be obtained, the process stops before DB connection, data processing, external transmission, or readiness exposure.
- Match the Account and Arn from AWS STS
GetCallerIdentityagainst the execution principal approved for the environment. AWS STS API - For connection destinations, retrieve the actual resource identifier, owning account, region, and necessary encryption keys from each service's management API (not just configuration strings) and verify them against the contract. For resources like S3 where the ARN does not include an account ID, perform owner verification separately, as appropriate for the target service. For example, S3's
HeadBucketallows specifying an expected owner. However, a 403 error can also occur due to other permission deficiencies, so do not conclude it's an owner mismatch. S3 HeadBucket - SaaS verifies independent evidence appropriate for the service, such as contract/tenant information from management APIs, or signed certificates whose issuer and validity period can be verified. If the billing entity cannot be verified via API, manual confirmation of the billing screen and contract acceptance is required.
The following is an outline of pre-startup checks. loadApprovedContract verifies the signature and version, performs schema validation on YAML snake_case, normalizes it to camelCase, and returns an independently distributed contract. verifySaaS is a dedicated adapter that matches the contract with the organization/tenant from a read-only management API or a certificate whose signature, issuer, and validity period have been verified, throwing an exception if verification fails. It either confirms affiliation with actual sending credentials or verifies a certificate bound to the reference and version of the Secret actually retrieved, returning a verified sending client. Both require implementation, and environment variables should not be used in place of actual measured values.
import { z } from "zod";
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
import { S3Client, HeadBucketCommand } from "@aws-sdk/client-s3";
try {
const env = z.object({ AWS_REGION: z.string().min(1) }).parse(process.env);
const contract = await loadApprovedContract(); // Independent distribution and signature verification
if (env.AWS_REGION !== contract.region) throw new Error("region mismatch");
const identity = await new STSClient({ region: contract.region })
.send(new GetCallerIdentityCommand({}));
if (identity.Account !== contract.accountId) throw new Error("account mismatch");
const s3 = new S3Client({ region: contract.region });
const bucketInfo = await s3.send(new HeadBucketCommand({
Bucket: contract.bucket,
ExpectedBucketOwner: contract.bucketOwnerAccountId,
}));
if (bucketInfo.BucketRegion !== contract.region) throw new Error("bucket region mismatch");
const saas = await verifySaaS(contract.saas); // Verify actual sending credentials
const verifiedConfig = { s3, bucket: contract.bucket, saas };
await startApplication(verifiedConfig); // Use verified connection destination and credentials
} catch {
console.error("boundary verification failed"); // Do not expose secret values or exception details
process.exit(1);
}The application uses injected clients and connection destinations and does not re-resolve from process.env or other credentials. Secret values are not output. This excerpt omits verification of execution roles, KMS, DB, network constraints, and billing entities. HeadBucket requires necessary permissions and reachability from a private network. Instead of granting SaaS administrator keys or broad AWS Describe/List permissions to runtime solely for ownership verification, some configurations measure with CI or dedicated pre-validation roles and verify a certificate bundling signature, expiration, and target revision at startup. In production, considering that the contract's IAM role ARN and STS's assumed-role ARN have different formats, roles should be verified using a reliable method. HeadBucket confirms bucket ownership and does not prove ownership or configuration of KMS keys or DBs. These should be verified separately with their respective management APIs.
STS indicates the caller and does not prove resource ownership in another account or the billing destination for SaaS. Do not falsely claim that items for which there is no means of obtaining proof were automatically verified at startup. Audit logs should retain verification results and contract versions, and secret values should not be output. Accept the availability impact of being unable to start due to temporary external API failures, and prepare monitoring and recovery procedures.
CI also statically detects the inclusion of internal endpoints, unauthorized IDs, and secret information references. However, string searches may miss dynamically generated or aliased items. Combine IaC plan and policy checks, network destination restrictions, and secret scans to complement real-environment verification.
Negative Testing and Customer-Centric Acceptance
Simply 'working with correct settings' doesn't guarantee boundary protection. At a minimum, try the following and confirm that no data is saved or transmitted externally upon failure.
- Provide credentials for a different account, and ensure CI's execution principal verification stops before
plan. Also, try unauthorized provider aliases or incorrect backends, and confirm that IaC guards terminate with an error at the relevantinit,plan, orapplystage, preventing progression to production changes. Protect backend initialization and state migration as separate stages. - Specify storage or keys of a different owner from the correct execution role, and ensure it stops at actual resource verification. Also verify SCP/key permission deficiencies and communication impossibility from private networks.
- Provide an incorrect SaaS tenant, revoked credentials, unverified billing entity, or inability to obtain a verification API, and do not transmit until agreed-upon verification is complete.
- The customer performs deployments, log viewing, secret information updates, backup restoration, and re-execution during failures themselves. Verify the customer's operational continuity and audit trails with the development company's delegation revoked.
- Upon termination, confirm data return/retention/deletion, key and credential revocation, and handover of DNS, certificates, state, and CI in accordance with the agreement.
AI increases the speed of writing code. However, if it's undecided whose land the house is being built on, discussions about relocating an entire completed mansion later will be repeated. The design to prevent speed from turning into rework is to first establish the boundaries of ownership and operation as a contract, and then uphold that contract in both implementation and verification.


