AwsApi Class
Use an AWS Lambda function that makes API calls as an event rule target.
Example
csharp
// Install: dotnet add package Amazon.CDK.Lib
var rule = new Rule(this, "Rule", new RuleProps {
Schedule = Schedule.Rate(Duration.Hours(1))
});
rule.AddTarget(new AwsApi(new AwsApiProps {
Service = "ECS",
Action = "updateService",
Parameters = new Dictionary<string, object> {
{ "service", "my-service" },
{ "forceNewDeployment", true }
}
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
rule := events.NewRule(this, jsii.String("Rule"), &RuleProps{
Schedule: events.Schedule_Rate(awscdk.Duration_Hours(jsii.Number(1))),
})
rule.AddTarget(targets.NewAwsApi(&AwsApiProps{
Service: jsii.String("ECS"),
Action: jsii.String("updateService"),
Parameters: map[string]interface{}{
"service": jsii.String("my-service"),
"forceNewDeployment": jsii.Boolean(true),
},
}))
Initializer
ts
new AwsApi(props: AwsApiProps)
python
AwsApi(props: AwsApiProps)
java
new AwsApi(AwsApiProps props)
csharp
new AwsApi(AwsApiProps props)
go
NewAwsApi(Props AwsApiProps)
Methods
bind(rule: IRuleRef, id?: string): RuleTargetConfigdef bind(self, rule: IRuleRef, id: typing.Optional[str] = None) -> RuleTargetConfigpublic RuleTargetConfig bind(IRuleRef rule, String id)public RuleTargetConfig Bind(IRuleRef rule, string? id = null)func Bind(Rule IRuleRef, Id *string) RuleTargetConfig#Returns a RuleTarget that can be used to trigger this AwsApi as a result from an EventBridge event.