# diagrid agent compute setup

Generate the cloud configuration for an Agent's serverless compute

### Description

Generate the cloud configuration that lets Diagrid start and stop the Agent's
workflow workers on serverless compute.

For --compute aws-agentcore it writes, as Terraform or CloudFormation:

- an IAM OIDC provider for the issuer of each region the project runs in;
- an IAM role that trusts the App ID's workload identity in each of those
  regions, and only that identity;
- a policy on the role allowing bedrock-agentcore:InvokeAgentRuntime and
  bedrock-agentcore:StopRuntimeSession on the Runtime and its endpoints.

Apply it in the AWS account that owns the Runtime, then attach the compute with
the role's ARN, which the output reports, as --compute-agentcore-role-arn.

When the Agent's App ID already has compute attached, --compute,
\--compute-agentcore-runtime-arn and --role-name default to its provider, its
Runtime and the name of its role, and the role keeps its IAM path, so the
output describes what is attached. --compute, when given, must name the
attached provider. The other flags override the attached values.

An IAM OIDC provider is shared by every App ID that uses the account in that
region. If the account already has one for a region's issuer, remove it from
the output, or import it, before applying.

The command only reads the Agent's App ID and the project's regions, so it can
run before compute is attached, given --compute and
\--compute-agentcore-runtime-arn.

```
diagrid agent compute setup <agent> [flags]
```

### Examples

```

  # Terraform for an Amazon Bedrock AgentCore Runtime
  diagrid agent compute setup my-agent --project my-project --compute aws-agentcore \
    --compute-agentcore-runtime-arn arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/order_worker-Xk92bQ

  # The same as a CloudFormation template, with a role name of your own
  diagrid agent compute setup my-agent --project my-project --compute aws-agentcore \
    --compute-agentcore-runtime-arn arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/order_worker-Xk92bQ \
    --role-name orders-invoker --output cloudformation

  # Terraform for the compute already attached to the agent
  diagrid agent compute setup my-agent --project my-project

```

### Options

```
  -p, --project string                         Name of existing project
      --compute string                         Serverless compute that runs the workflow workers: aws-agentcore. Defaults to the provider of the attached compute
      --compute-agentcore-runtime-arn string   ARN of the Amazon Bedrock AgentCore Runtime that runs the workers (--compute aws-agentcore). Defaults to the Runtime of the attached compute
      --role-name string                       Name of the IAM role to create. Defaults to the name of the attached compute's role, or diagrid-<App ID>-invoker
  -o, --output string                          Format of the configuration: terraform, cloudformation (default "terraform")
  -h, --help                                   help for setup
```

### Options inherited from parent commands

```
      --api-key string   Diagrid Cloud API key
```

### SEE ALSO

- [diagrid agent compute](./compute.md)	 - Set up serverless compute for an Agent's workflow workers
