Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a construct to make/schedule AWS API calls #2538

Closed
jogold opened this issue May 13, 2019 · 1 comment · Fixed by #3720
Closed

Add a construct to make/schedule AWS API calls #2538

jogold opened this issue May 13, 2019 · 1 comment · Fixed by #3720
Labels
feature-request A feature should be added or improved.

Comments

@jogold
Copy link
Contributor

jogold commented May 13, 2019

The cdk could benefit from an AwsLambda or ScheduledAwsLambda construct that could be used like this:

new ScheduledAwsLambda(this, 'StopInstance', {
  service: 'RDS',
  action: 'stopDBInstance',
  parameters: {
    DBInstanceIdentifier: '...',
  },
  scheduleExpression: 'cron(0 1 * * ? *)'
});

new ScheduledAwsLambda(this, 'StartExecution', {
  service: 'StepFunctions',
  action: 'startExecution',
  parameters: {
    stateMachineArn: '...',
  },
  scheduleExpression: 'cron(0 1 * * ? *)',
});

The lambda function takes the service, action and parameter as event and simply makes the call using aws-sdk-js.

See also discussion started in #1850

@jogold jogold added the feature-request A feature should be added or improved. label May 13, 2019
@jogold
Copy link
Contributor Author

jogold commented Jun 6, 2019

@eladb how about "generating" the code for these classes from the JSON files or type definitions of the aws-sdk?

So if I want to roll a container everyday at midnight I could do:

new ScheduledAwsEcsUpdateService(this, 'Roll', { // The class for the ECS.UpdateService API call
  params: { // This is typed :)
    service: myService.serviceName,
    cluster: myCluster.clusterName,
    forceNewDeployment: true
  },
  scheduleExpression: 'cron(0 0 * * ? *)'
});

jogold added a commit to jogold/aws-cdk that referenced this issue Aug 20, 2019
Add a `AwsApi` rule target to make AWS API calls.

Comparable to the `AwsCustomResource` in terms of API and IAM permissions.

Closes aws#2538
eladb pushed a commit that referenced this issue Aug 27, 2019
Add a AwsApi rule target to make AWS API calls.

Comparable to the AwsCustomResource in terms of API and IAM permissions.

Closes #2538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant