You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a CF custom resource to make calls on the AWS API using AWS SDK JS v2. There are lots of use cases when the CF coverage is not sufficient and adding a simple API call can solve the problem. It could be also used internally to create better L2 constructs.
Does this fit in the scope of the cdk?
If accepted, I think that ideally it should live in its own lerna package.
API:
```ts
new AwsSdkJsCustomResource(this, 'AwsSdk', {
onCreate: { // AWS SDK call when resource is created (defaults to onUpdate)
service: '...',
action: '...',
parameters: { ... }
}.
onUpdate: { ... }. // AWS SDK call when resource is updated (defaults to onCreate)
onDelete: { ... }, // AWS SDK call when resource is deleted
policyStatements: [...] // Automatically derived from the calls if not specified
});
```
Fargate scheduled task example (could be used in `@aws-cdk/aws-ecs` to implement the missing `FargateEventRuleTarget`):
```ts
const vpc = ...;
const cluster = new ecs.Cluster(...);
const taskDefinition = new ecs.FargateTaskDefinition(...);
const rule = new events.EventRule(this, 'Rule', {
scheduleExpression: 'rate(1 hour)',
});
const ruleRole = new iam.Role(...);
new AwsSdkJsCustomResource(this, 'PutTargets', {
onCreate: {
service: 'CloudWatchEvents',
action: 'putTargets',
parameters: {
Rule: rule.ruleName,
Targets: [
Arn: cluster.clusterArn,
Id: ...,
EcsParameters: {
taskDefinitionArn: taskDefinition.taskDefinitionArn,
LaunchType: 'FARGATE',
NetworkConfiguration: {
awsvpcConfiguration: {
AssignPublicIp: 'DISABLED',
SecurityGroups: [...],
Subnets: vpc.privateSubnets.map(subnet => subnet.subnetId),
},
},
RoleArn: ruleRole.roleArn
}
]
}
}
})
```
0 commit comments