> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/ai-agents-deployment/aws-agent-core/environment.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Environment

Configure the environment and infrastructure definition that target AWS Agent Core for an agent deployment.

The environment defines where an agent deploys. It groups your deployment targets, and its infrastructure definition describes the AWS Agent Core target, such as the connector, region, gateway, and networking. This page shows you how to add an AWS Agent Core infrastructure definition.

{% hint style="info" %}
Agent deployments are behind the feature flag `CDS_AGENT_RUNTIME_DEPLOYMENT`. Contact [Harness Support](mailto:support@harness.io) to enable the feature.
{% endhint %}

You need a registered agent service with **AWS Agent Core** as its deploy target and an AWS connector with permission to deploy to AgentCore. For all prerequisites, go to [Before you begin](https://developer.harness.io/continuous-delivery/use-continuous-delivery/ai-agents-deployment/aws-agent-core/overview.md#before-you-begin) on the overview. For how environments and infrastructure definitions work in CD, go to [Environment overview](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/environment-overview.md).

***

### Create the environment <a href="#create-the-environment" id="create-the-environment"></a>

Create an environment for your agent deployments, or reuse an existing one. Set the environment type to **Production** or **Pre-Production** based on the target. Go to [Create environments](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/create-environments.md) to add one.

***

### Add an infrastructure definition <a href="#add-an-infrastructure-definition" id="add-an-infrastructure-definition"></a>

The infrastructure definition describes the cloud target for one environment. In the environment, open the **Infrastructure Definitions** tab and select **Infrastructure Definition** to add one.

1. Enter a name for the infrastructure definition.
2. Set **Deployment Type** to **AI Agent Services**.
3. Under **Select Infrastructure Type**, select **AWS Agent Core**.
4. Under **Cluster Details**, configure the connector and target. Go to [Configure the infrastructure](#configure-the-infrastructure) for the fields.
5. Select **Save**.

#### Configure the infrastructure <a href="#configure-the-infrastructure" id="configure-the-infrastructure"></a>

The cluster details define the connector Harness uses and the AgentCore target the agent deploys to. Configure the following fields:

* **Connector:** The AWS connector with permission to deploy to AgentCore.
* **Region:** A region where AgentCore is available, for example `us-east-1`.
* **Networking Type:** Select **None** for the default, or **VPC** when the agent must reach private resources. When you select **VPC**, provide the subnets, which must all belong to the same VPC, and optionally the security groups.

**Gateway (optional):** An AgentCore Gateway enables weighted canary traffic shifting between agent versions. If you do not need traffic switching, leave the gateway fields empty. Without a gateway, each deploy performs a direct endpoint cutover and the traffic shift step in the pipeline is skipped.

Select **Auto-configure Gateway (if required)** to have Harness create the AgentCore Gateway and its target rule during the first deploy, instead of provisioning a gateway yourself. Enter the **Gateway Role ARN**, the execution role the gateway itself assumes, not a role Harness assumes. Select an **Authorizer Type** to protect the created gateway: **AWS\_IAM**, **CUSTOM\_JWT**, **AUTHENTICATE\_ONLY**, or **NONE**. Harness shows additional fields based on the authorizer type you select; for **CUSTOM\_JWT**, provide a discovery URL and at least one of allowed audiences, allowed clients, allowed scopes, or custom claims. This authorizer protects the gateway itself and is separate from the agent authorizer on the agent service. Go to [Configure an agent authorizer](https://developer.harness.io/continuous-delivery/use-continuous-delivery/ai-agents-deployment/aws-agent-core/agent-service.md#configure-an-agent-authorizer) to review the service-level authorizer that controls invocation of the agent runtime. If you also provide **arn** through the YAML editor while auto-configure is selected, Harness skips automatic provisioning entirely and falls back to the manual gateway handling described below, using the gateway and rule you specify.

{% hint style="info" %}
**Gateway Role ARN** is the execution role for the gateway itself, not the AWS connector's credentials. Give it a trust policy that allows `bedrock-agentcore.amazonaws.com` to assume it, and grant only `bedrock-agentcore:GetGateway` and `bedrock-agentcore:GetConfigurationBundleVersion`. Harness always names auto-configured gateways with the fixed prefix `harness-agentcore-`, so scope both the trust policy's `aws:SourceArn` condition and the permission policy's resource to `arn:aws:bedrock-agentcore:<region>:<account-id>:gateway/harness-agentcore-*`. The wildcard is required because the exact gateway name is not known until Harness creates it, but Harness fixes the prefix and never uses it for a gateway it does not manage, so the policy stays as narrow as possible.
{% endhint %}

When **Auto-configure Gateway (if required)** is selected, you do not need to enter a **Gateway Rule ID**. Harness creates the target rule for you and carries the resulting gateway ARN and rule ID forward to the traffic shift and rollback steps automatically.

{% hint style="info" %}
Harness marks what it creates on the gateway so it can recognize and safely reuse it on later deploys, shifts, and rollbacks. The gateway name is always `harness-agentcore-<hash>`, and Harness tags it `harness.io/managed-by: agentcore-deploy`, with the description `Managed by Harness AgentCore deploy (identity: <hash>)` as a fallback if tags cannot be read. The target rule gets the description `harness-managed-agentcore-route` and priority `1000000`. If the gateway ever has more than one rule with this description, Harness uses the one at this priority to disambiguate.
{% endhint %}

<details>

<summary>AWS Agent Core infrastructure definition YAML with automatic gateway creation</summary>

```yaml
infrastructureDefinition:
  name: Agent Core CD Play
  identifier: Agent_Core_CD_Play
  orgIdentifier: default
  projectIdentifier: Demo
  environmentRef: Aws_Agent_Core
  deploymentType: AiAgent
  type: AwsAgentCore
  spec:
    connectorRef: account.aws_connector
    region: us-east-1
    networking:
      type: none
    gateway:
      autoConfigure: true
      roleArn: arn:aws:iam::123456789012:role/agentcore-gateway-role
      authorizer:
        type: CUSTOM_JWT
        spec:
          discoveryUrl: https://idp.example.com/.well-known/openid-configuration
          allowedAudiences:
            - my-agent-api
          allowedScopes:
            - agent:invoke
  allowSimultaneousDeployments: false
```

</details>

When **Auto-configure Gateway (if required)** is cleared, the default, provision the gateway yourself and point Harness at it. Complete the following steps in order:

1. Deploy the agent once without a gateway configured. This initial deploy creates the first live AgentCore endpoint.
2. Note the live endpoint ARN from the deployed agent. Provision an AgentCore Gateway outside Harness, through Terraform, CDK, or the AWS console, and create a static target rule in the gateway that points to the live endpoint ARN.
3. Return to this infrastructure definition, enter the **Gateway ARN** and **Gateway Rule ID** from the gateway you provisioned, and save.

After the gateway is in place, Harness manages the live and candidate endpoints and shifts traffic between them according to the canary steps in your pipeline.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-93659e3876d63636ce9a5d51fa96aef5c5b7670d%2Finfra-aws-cluster.png?alt=media" alt="Edit Infrastructure panel for AWS Agent Core showing connector, region, gateway ARN, gateway rule ID, and networking type"><figcaption><p>Click to view full size</p></figcaption></figure>

<details>

<summary>AWS Agent Core infrastructure definition YAML with a manually provisioned gateway</summary>

```yaml
infrastructureDefinition:
  name: Agent Core CD Play
  identifier: Agent_Core_CD_Play
  orgIdentifier: default
  projectIdentifier: Demo
  environmentRef: Aws_Agent_Core
  deploymentType: AiAgent
  type: AwsAgentCore
  spec:
    connectorRef: account.aws_connector
    region: us-east-1
    networking:
      type: none
    gateway:
      arn: arn:aws:bedrock-agentcore:us-east-1:123456789012:gateway/my-agent-gateway
      ruleId: <gateway-rule-id>
  allowSimultaneousDeployments: false
```

</details>

***

### Next steps <a href="#next-steps" id="next-steps"></a>

With the infrastructure defined, build the pipeline stage that wires the service, environment, and infrastructure together.

* [Canary deployment](https://developer.harness.io/continuous-delivery/use-continuous-delivery/ai-agents-deployment/aws-agent-core/canary-deployment.md)
* [Agent service](https://developer.harness.io/continuous-delivery/use-continuous-delivery/ai-agents-deployment/aws-agent-core/agent-service.md)

{% @harness-feedback/feedback %}
