

# CreateConnection

Creates a connection to a data source, such as an AWS Glue Data Catalog, an Amazon Bedrock knowledge base, or a third-party data catalog through an AWS Glue connection. GetConnection returns the connection's status.

## Request Parameters
<a name="API_CreateConnection_RequestParameters"></a>

 ** accessConfig **   
The access configuration for the data source, which names the AWS Identity and Access Management (IAM) role for data access. Optional.  
For `GLUE_DATA_CATALOG` and `BEDROCK_KNOWLEDGE_BASE`, `iamRole` is the IAM role that AWS Context assumes to read the source and the AWS Glue connections in `glueConnectionMappings`. If you omit `accessConfig` or set no variant, AWS Context reads them with your own credentials. This applies whether the source is in your account or another account. For a source in another account, AWS Context checks when it creates the connection that `iamRole` can read the source, and the request fails if it can't. A source in another account with no `iamRole` isn't checked when the connection is created. An `accessConfig` with no variant is stored as absent and is not returned on the connection.  
For `DATABRICKS` and `SNOWFLAKE`, AWS Glue reads the source with the `ROLE_ARN` of the AWS Glue connection in `dataSource`, not with `accessConfig`. For these types, `accessConfig` is reserved for other roles.  
Type: [AccessConfig](API_AccessConfig.md) object  
 **Note: **This object is a Union. Only one member of this object can be specified or returned.  
Required: No

 ** acknowledgements **   
The conditions that you acknowledge AWS Context can't honor. Specify `CUSTOMER_MANAGED_KEY` when the knowledge base is encrypted with an AWS KMS customer managed key and you accept that AWS Context stores the ingested data under AWS owned keys. If you omit it, creating a connection to such a knowledge base fails with `ValidationException`. An unknown or repeated value also fails with `ValidationException`.  
Type: Array of strings  
Array Members: Minimum number of 0 items. Maximum number of 10 items.  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[A-Z][A-Z0-9_]*`   
Required: No

 ** clientToken **   
A client idempotency token. It is optional, so the AWS SDKs can generate it automatically and reuse it on retries. A retry with an identical request returns the original connection. A different request returns `ValidationException`. `acknowledgements`, `tags` and, once the connection is `ACTIVE`, `publish` are not compared with the original request. A create refused for a missing acknowledgement records no token.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[\x21-\x7E]+`   
Required: No

 ** dataSource **   
The external data source that this connection binds to: its `type` and `location.arn`. The ARN must be in your account, except for `GLUE_DATA_CATALOG`, where it can name a catalog or an AWS Glue connection in another account.  
+  `GLUE_DATA_CATALOG` - An AWS Glue Data Catalog ARN (`:catalog` or `:catalog/<path>`), or the ARN of an existing AWS Glue connection (`:connection/<name>`) for a federated AWS data source such as Amazon Redshift or Amazon RDS. The AWS Glue connection must be a unified connection (ConnectionSchemaVersion 2) in your partition and Region that you can read. You can't specify `scope` with an AWS Glue connection ARN. While AWS Glue is still validating the connection, the request fails with `ConflictException`. If its validation failed, the request fails with `AccessDeniedException`.
+  `DATABRICKS` or `SNOWFLAKE` - The ARN of an existing AWS Glue connection whose AWS Glue ConnectionType matches `type`. AWS Context validates its Credential Broker settings, if present, and doesn't store them.
Type: [DataSourceReference](API_DataSourceReference.md) object  
Required: Yes

 ** glueConnectionMappings **   
The AWS Glue connection to use for each `redshiftNamespace`, each `rdsInstance` and `rdsDatabase` pair, or each `snowflakeDatabase` in `scope`, keyed by `path`. Optional. You can specify 0–20 entries. The following rules apply:  
+ Once an entry names a level, every resource of that level in `scope` needs an entry. While an entry names `rdsInstance`, every selector that names an `rdsInstance` must also name its `rdsDatabase`.
+  `redshiftNamespace` and `rdsInstance` entries require `dataSource` to be an AWS Glue Data Catalog ARN. `accessConfig.iamRole` is optional.
+  `snowflakeDatabase` entries require `dataSource` to be an AWS Glue connection ARN.
+ While any entry is present, `scope` cannot contain a selector that names only a catalog or a `glueService`, because such a selector covers every resource of the catalog or service. Otherwise, a selector with a `glueService` segment follows these rules as it would without that segment. An entry's `path` never names `glueService`.
+ A selector that names only `glueService` `REDSHIFT` or `RDS`, with no namespace or instance, cannot be combined with any entry. Such a connection reads only the service's metadata, and you cannot query its data.
Type: Array of [GlueConnectionMapping](API_GlueConnectionMapping.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 20 items.  
Required: No

 ** ingestionConfig **   
The ingestion configuration: the IAM role that a data producer (AWS Glue Data Catalog or Amazon Bedrock knowledge base) assumes to push data into this connection's agent contexts. It is separate from `accessConfig`, which names the role that AWS Context assumes to read the source. Required, because a connection can't ingest data without a role that its data producer can assume. You must have `iam:PassRole` permission to pass this role to the data producer, and the role must be in your account.  
Type: [IngestionConfig](API_IngestionConfig.md) object  
Required: Yes

 ** name **   
The name of the connection. Required. You can change it later with UpdateConnection. Starts with a letter and contains 3–63 ASCII letters, digits, and hyphens.  
Type: String  
Length Constraints: Minimum length of 3. Maximum length of 63.  
Pattern: `[a-zA-Z][a-zA-Z0-9-]*`   
Required: Yes

 ** publish **   
Specifies whether to configure catalog synchronization and wait for it to be provisioned during this call. If you omit it, the default is `true`. For a `DATABRICKS` or `SNOWFLAKE` connection, `false` validates only the AWS Glue connection. The connection is returned as `CREATING` with `subStatus` `GLUE_CONNECTION_VALIDATED`, and you publish it later by calling UpdateConnection with `publish` set to `true`. Ignored for `GLUE_DATA_CATALOG` and `BEDROCK_KNOWLEDGE_BASE` connections, which have no sync job.  
Type: Boolean  
Required: No

 ** scope **   
Optional hierarchical subset of the data source to ingest. Absent means the whole source. A DATABRICKS scope names at most one `databricksCatalog`, and a SNOWFLAKE scope one `snowflakeDatabase`. A GLUE\_DATA\_CATALOG scope can select by service with a `glueService` segment (see `DataSourceScope`). An unknown service name, a repeated or misplaced `glueService` segment, a later level of another service, or `glueService` on another connection type returns ValidationException.  
Type: [DataSourceScope](API_DataSourceScope.md) object  
Required: No

 ** syncSchedule **   
How often AWS Context re-syncs a `DATABRICKS` or `SNOWFLAKE` source. If you omit it, the default is `DAILY`. Not accepted for `GLUE_DATA_CATALOG` and `BEDROCK_KNOWLEDGE_BASE` connections. You can change it with UpdateConnection.  
Type: [SyncSchedule](API_SyncSchedule.md) object  
 **Note: **This object is a Union. Only one member of this object can be specified or returned.  
Required: No

 ** tags **   
Tags to add to the connection when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with `aws:`. To add tags, you also need `context:TagResource` permission on the new connection. If you specify more than 50 user tags, the request fails with `ServiceQuotaExceededException`, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with `ValidationException`.  
Type: String to string map  
Map Entries: Minimum number of 0 items. Maximum number of 200 items.  
Key Length Constraints: Minimum length of 1. Maximum length of 128.  
Value Length Constraints: Minimum length of 0. Maximum length of 256.  
Required: No

## Response Elements
<a name="API_CreateConnection_ResponseElements"></a>

The following elements are returned by the service.

 ** accessConfig **   
Per-connection access configuration: the IAM role used for data access.  
Type: [AccessConfig](API_AccessConfig.md) object  
 **Note: **This object is a Union. Only one member of this object can be specified or returned.

 ** arn **   
The ARN of the connection.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 180.  
Pattern: `arn:(aws|aws-cn|aws-us-gov):context:[a-z0-9\-]{1,32}:\d{12}:connection/[a-z0-9]+(-[a-z0-9]+)*` 

 ** createdAt **   
The date and time when the connection was created.  
Type: Timestamp

 ** dataSource **   
The typed reference to the external data source that this connection binds to. Its `type`, the authoritative kind of data source, is in `dataSource.type`.  
Type: [DataSourceReference](API_DataSourceReference.md) object

 ** failure **   
The reason the connection is FAILED. Absent in every other status.  
Type: [ConnectionFailure](API_ConnectionFailure.md) object

 ** glueConnectionMappings **   
The AWS Glue connection for each `redshiftNamespace`, each `rdsInstance` and `rdsDatabase` pair, or each `snowflakeDatabase` in `scope`. Absent when none is configured.  
Type: Array of [GlueConnectionMapping](API_GlueConnectionMapping.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 20 items.

 ** id **   
The ID of the connection.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `[a-z0-9]+(-[a-z0-9]+)*` 

 ** ingestionConfig **   
The connection's ingestion configuration (the IAM role a data producer assumes to push into this connection). Absent when no ingestion role is configured.  
Type: [IngestionConfig](API_IngestionConfig.md) object

 ** name **   
The name of the connection. You set it when you create the connection and can change it with UpdateConnection. Uses the same constraints as an agent context name. Always present.  
Type: String  
Length Constraints: Minimum length of 3. Maximum length of 63.  
Pattern: `[a-zA-Z][a-zA-Z0-9-]*` 

 ** scope **   
The hierarchical subset of the data source this connection ingests.  
Type: [DataSourceScope](API_DataSourceScope.md) object

 ** status **   
The connection's status. Valid values:  
+  `CREATING` - Validation or provisioning is still in progress.
+  `ACTIVE` - The data source is reachable and, for a `DATABRICKS` or `SNOWFLAKE` connection, AWS Glue has provisioned catalog synchronization and returned its crawler ARN. This doesn't mean that a crawl has started or completed.
+  `UPDATING` - The connection is being updated.
+  `DELETING` - The connection is being deleted.
+  `FAILED` - Validation or provisioning failed, and the connection can't recover.
Type: String  
Valid Values: `CREATING | ACTIVE | UPDATING | DELETING | FAILED` 

 ** subStatus **   
The last milestone a third-party connection's lifecycle reached. Present in two statuses: CREATING, where it shows the resources provisioned so far, and DELETING, where it shows the resources removed so far. Absent in every other status and while nothing has been done yet in the current direction. CREATING at GLUE\_CONNECTION\_VALIDATED on a connection created with `publish: false` means it is waiting for UpdateConnection `publish: true`.  
Type: String  
Valid Values: `GLUE_CONNECTION_CREATED | GLUE_CONNECTION_VALIDATED | SYNC_JOB_CREATED` 

 ** syncSchedule **   
The effective sync schedule. Present for `DATABRICKS` and `SNOWFLAKE` connections (`DAILY` if you didn't specify one). Absent for `GLUE_DATA_CATALOG` and `BEDROCK_KNOWLEDGE_BASE` connections, which are event-driven.  
Type: [SyncSchedule](API_SyncSchedule.md) object  
 **Note: **This object is a Union. Only one member of this object can be specified or returned.

 ** updatedAt **   
When the resource last changed. Equal to `createdAt` until the first update.  
Type: Timestamp

## Errors
<a name="API_CreateConnection_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AccessDeniedException **   
You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.    
 ** message **   
A message that describes the error.
HTTP Status Code: 403

 ** ConflictException **   
The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.    
 ** message **   
A message that describes the error.  
 ** resourceId **   
The ID of the resource that caused the conflict. When several resources caused it, a comma-separated list of their IDs.  
 ** resourceType **   
The type of the resource that caused the conflict.  
Valid values:  
+  `agent-context` - An agent context.
+  `connection` - A connection.
+  `curation-policy` - A curation policy.
+  `evaluation` - Reserved for future use.
+  `ontology` - An ontology.
+  `ontology-induction` - An ontology induction.
+  `resource-policy` - A resource-based policy.
HTTP Status Code: 409

 ** InternalServerException **   
The request failed because of an internal error. Retry the request.    
 ** message **   
A message that describes the error.
HTTP Status Code: 500

 ** ResourceNotFoundException **   
The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.    
 ** message **   
A message that describes the error.  
 ** resourceId **   
The ID of the resource that was not found.  
 ** resourceType **   
The type of the resource that wasn't found.  
Valid values:  
+  `agent-context` - An agent context.
+  `connection` - A connection.
+  `curation-policy` - A curation policy.
+  `evaluation` - Reserved for future use.
+  `ontology` - An ontology.
+  `ontology-induction` - An ontology induction.
+  `resource-policy` - A resource-based policy.
HTTP Status Code: 404

 ** ServiceQuotaExceededException **   
The request would exceed a service quota. Check the quota that `quotaCode` names, reduce your usage, and then retry the request.    
 ** message **   
A message that describes the error.  
 ** quotaCode **   
The code of the quota that the request would exceed.  
 ** resourceId **   
The ID of the resource that the quota applies to.  
 ** resourceType **   
The type of the resource that the quota applies to.  
Valid values:  
+  `agent-context` - An agent context.
+  `connection` - A connection.
+  `curation-policy` - A curation policy.
+  `evaluation` - Reserved for future use.
+  `ontology` - An ontology.
+  `ontology-induction` - An ontology induction.
+  `resource-policy` - A resource-based policy.  
 ** serviceCode **   
The code of the service that owns the quota.
HTTP Status Code: 402

 ** ThrottlingException **   
The request was denied because it exceeded a request rate quota. Wait, then retry the request.    
 ** message **   
A message that describes the error.  
 ** quotaCode **   
The code of the quota that throttled the request.  
 ** retryAfterSeconds **   
The number of seconds to wait before you retry the request, if AWS Context provides one.  
 ** serviceCode **   
The code of the service whose quota throttled the request.
HTTP Status Code: 429

 ** ValidationException **   
The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.    
 ** fieldList **   
The fields that failed validation, each with a message that describes why.  
 ** message **   
A message that describes the error.  
 ** reason **   
The reason that the input failed validation. Valid values:  
+  `unknownOperation` - The operation isn't recognized.
+  `cannotParse` - The request couldn't be parsed.
+  `fieldValidationFailed` - One or more fields failed validation. `fieldList` describes them.
+  `other` - Another reason. `message` describes it.
HTTP Status Code: 400

## See Also
<a name="API_CreateConnection_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/context-2022-07-26/CreateConnection) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/context-2022-07-26/CreateConnection) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/context-2022-07-26/CreateConnection) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/context-2022-07-26/CreateConnection) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/context-2022-07-26/CreateConnection) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/context-2022-07-26/CreateConnection) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/context-2022-07-26/CreateConnection) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/context-2022-07-26/CreateConnection) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/context-2022-07-26/CreateConnection) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/context-2022-07-26/CreateConnection) 