- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreateConnectionCommand
Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.
For more information, see Connections for endpoint targets in the Amazon EventBridge User Guide.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { EventBridgeClient, CreateConnectionCommand } from "@aws-sdk/client-eventbridge"; // ES Modules import
// const { EventBridgeClient, CreateConnectionCommand } = require("@aws-sdk/client-eventbridge"); // CommonJS import
const client = new EventBridgeClient(config);
const input = { // CreateConnectionRequest
Name: "STRING_VALUE", // required
Description: "STRING_VALUE",
AuthorizationType: "BASIC" || "OAUTH_CLIENT_CREDENTIALS" || "API_KEY", // required
AuthParameters: { // CreateConnectionAuthRequestParameters
BasicAuthParameters: { // CreateConnectionBasicAuthRequestParameters
Username: "STRING_VALUE", // required
Password: "STRING_VALUE", // required
},
OAuthParameters: { // CreateConnectionOAuthRequestParameters
ClientParameters: { // CreateConnectionOAuthClientRequestParameters
ClientID: "STRING_VALUE", // required
ClientSecret: "STRING_VALUE", // required
},
AuthorizationEndpoint: "STRING_VALUE", // required
HttpMethod: "GET" || "POST" || "PUT", // required
OAuthHttpParameters: { // ConnectionHttpParameters
HeaderParameters: [ // ConnectionHeaderParametersList
{ // ConnectionHeaderParameter
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
QueryStringParameters: [ // ConnectionQueryStringParametersList
{ // ConnectionQueryStringParameter
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
BodyParameters: [ // ConnectionBodyParametersList
{ // ConnectionBodyParameter
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
},
},
ApiKeyAuthParameters: { // CreateConnectionApiKeyAuthRequestParameters
ApiKeyName: "STRING_VALUE", // required
ApiKeyValue: "STRING_VALUE", // required
},
InvocationHttpParameters: {
HeaderParameters: [
{
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
QueryStringParameters: [
{
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
BodyParameters: [
{
Key: "STRING_VALUE",
Value: "STRING_VALUE",
IsValueSecret: true || false,
},
],
},
ConnectivityParameters: { // ConnectivityResourceParameters
ResourceParameters: { // ConnectivityResourceConfigurationArn
ResourceConfigurationArn: "STRING_VALUE", // required
},
},
},
InvocationConnectivityParameters: {
ResourceParameters: {
ResourceConfigurationArn: "STRING_VALUE", // required
},
},
KmsKeyIdentifier: "STRING_VALUE",
};
const command = new CreateConnectionCommand(input);
const response = await client.send(command);
// { // CreateConnectionResponse
// ConnectionArn: "STRING_VALUE",
// ConnectionState: "CREATING" || "UPDATING" || "DELETING" || "AUTHORIZED" || "DEAUTHORIZED" || "AUTHORIZING" || "DEAUTHORIZING" || "ACTIVE" || "FAILED_CONNECTIVITY",
// CreationTime: new Date("TIMESTAMP"),
// LastModifiedTime: new Date("TIMESTAMP"),
// };
CreateConnectionCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
AuthParameters Required | CreateConnectionAuthRequestParameters | undefined | The authorization parameters to use to authorize with the endpoint. You must include only authorization parameters for the |
AuthorizationType Required | ConnectionAuthorizationType | undefined | The type of authorization to use for the connection. OAUTH tokens are refreshed when a 401 or 407 response is returned. |
Name Required | string | undefined | The name for the connection to create. |
Description | string | undefined | A description for the connection to create. |
InvocationConnectivityParameters | ConnectivityResourceParameters | undefined | For connections to private APIs, the parameters to use for invoking the API. For more information, see Connecting to private APIs in the Amazon EventBridge User Guide . |
KmsKeyIdentifier | string | undefined | The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this connection. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN. If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt the connection. For more information, see Identify and view keys in the Key Management Service Developer Guide. |
CreateConnectionCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
ConnectionArn | string | undefined | The ARN of the connection that was created by the request. |
ConnectionState | ConnectionState | undefined | The state of the connection that was created by the request. |
CreationTime | Date | undefined | A time stamp for the time that the connection was created. |
LastModifiedTime | Date | undefined | A time stamp for the time that the connection was last updated. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | You do not have the necessary permissions for this action. |
InternalException | server | This exception occurs due to unexpected causes. |
LimitExceededException | client | The request failed because it attempted to create resource beyond the allowed service quota. |
ResourceAlreadyExistsException | client | The resource you are trying to create already exists. |
ResourceNotFoundException | client | An entity that you specified does not exist. |
ThrottlingException | client | This request cannot be completed due to throttling issues. |
EventBridgeServiceException | Base exception class for all service exceptions from EventBridge service. |