Authorization Class
Authorization type for an API Destination Connection.
Example
ts
const connection = new events.Connection(this, 'Connection', {
authorization: events.Authorization.apiKey('x-api-key', SecretValue.secretsManager('ApiSecretName')),
description: 'Connection with API Key x-api-key',
});
const destination = new events.ApiDestination(this, 'Destination', {
connection,
endpoint: 'https://example.com',
description: 'Calling example.com with API key x-api-key',
});
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.rate(Duration.minutes(1)),
targets: [new targets.ApiDestination(destination)],
});
python
connection = events.Connection(self, "Connection",
authorization=events.Authorization.api_key("x-api-key", SecretValue.secrets_manager("ApiSecretName")),
description="Connection with API Key x-api-key"
)
destination = events.ApiDestination(self, "Destination",
connection=connection,
endpoint="https://example.com",
description="Calling example.com with API key x-api-key"
)
rule = events.Rule(self, "Rule",
schedule=events.Schedule.rate(Duration.minutes(1)),
targets=[targets.ApiDestination(destination)]
)
java
Connection connection = Connection.Builder.create(this, "Connection")
.authorization(Authorization.apiKey("x-api-key", SecretValue.secretsManager("ApiSecretName")))
.description("Connection with API Key x-api-key")
.build();
ApiDestination destination = ApiDestination.Builder.create(this, "Destination")
.connection(connection)
.endpoint("https://example.com")
.description("Calling example.com with API key x-api-key")
.build();
Rule rule = Rule.Builder.create(this, "Rule")
.schedule(Schedule.rate(Duration.minutes(1)))
.targets(List.of(new ApiDestination(destination)))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var connection = new Connection(this, "Connection", new ConnectionProps {
Authorization = Authorization.ApiKey("x-api-key", SecretValue.SecretsManager("ApiSecretName")),
Description = "Connection with API Key x-api-key"
});
var destination = new ApiDestination(this, "Destination", new ApiDestinationProps {
Connection = connection,
Endpoint = "https://example.com",
Description = "Calling example.com with API key x-api-key"
});
var rule = new Rule(this, "Rule", new RuleProps {
Schedule = Schedule.Rate(Duration.Minutes(1)),
Targets = new [] { new ApiDestination(destination) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
connection := events.NewConnection(this, jsii.String("Connection"), &ConnectionProps{
Authorization: events.Authorization_ApiKey(jsii.String("x-api-key"), awscdk.SecretValue_SecretsManager(jsii.String("ApiSecretName"))),
Description: jsii.String("Connection with API Key x-api-key"),
})
destination := events.NewApiDestination(this, jsii.String("Destination"), &ApiDestinationProps{
Connection: Connection,
Endpoint: jsii.String("https://example.com"),
Description: jsii.String("Calling example.com with API key x-api-key"),
})
rule := events.NewRule(this, jsii.String("Rule"), &RuleProps{
Schedule: events.Schedule_Rate(awscdk.Duration_Minutes(jsii.Number(1))),
Targets: []IRuleTarget{
targets.NewApiDestination(destination),
},
})
Initializer
ts
new Authorization()
python
Authorization()
java
new Authorization()
csharp
new Authorization()
go
NewAuthorization()
Methods
apiKey(apiKeyName: string, apiKeyValue: SecretValue): Authorization // chainable@staticmethod def api_key(api_key_name: str, api_key_value: SecretValue) -> Authorizationpublic static Authorization apiKey(String apiKeyName, SecretValue apiKeyValue)public static Authorization ApiKey(string apiKeyName, SecretValue apiKeyValue)func ApiKey(ApiKeyName *string, ApiKeyValue SecretValue) Authorizationstatic#Use API key authorization.
API key authorization has two components: an API key name and an API key value. What these are depends on the target of your connection.
basic(username: string, password: SecretValue): Authorization // chainable@staticmethod def basic(username: str, password: SecretValue) -> Authorizationpublic static Authorization basic(String username, SecretValue password)public static Authorization Basic(string username, SecretValue password)func Basic(Username *string, Password SecretValue) Authorizationstatic#Use username and password authorization.
oauth(props: OAuthAuthorizationProps): Authorization // chainable@staticmethod def oauth(props: OAuthAuthorizationProps) -> Authorizationpublic static Authorization oauth(OAuthAuthorizationProps props)public static Authorization Oauth(OAuthAuthorizationProps props)func Oauth(Props OAuthAuthorizationProps) Authorizationstatic#Use OAuth authorization.