Data source and Resource for generic signed API request #20225
Labels
enhancement
Requests to existing resources that expand the functionality or scope.
new-data-source
Introduces a new data source.
new-resource
Introduces a new resource.
Community Note
Description
There are many things supported by the AWS CLI that aren't supported by the Terraform AWS provider. Unfortunately, this will always be the case as it takes months, or sometimes years, for new AWS features to be supported in the Terraform AWS provider.
To use these features, engineers often resort to using the AWS CLI with the external data source. The problem is, how do you provide appropriate credentials to the AWS CLI commands? The easiest way is to pass it a profile argument, but it becomes complicated if you want to be able to support the same credential sources as the AWS provider (access keys, profiles, environment variables, assumed roles, etc.). Additionally, it requires having the AWS CLI installed, which may not always be the case, and it becomes very difficult to track the state of resources created/modified this way.
What if we could provide a data source and resource for generic, signed requests against the AWS APIs? Allow engineers to specify an API endpoint and request parameters, have the provider format and sign the request using the same credentials the provider is configured with, make the request, and then output the response parameters? For the data source variant, do not track anything in state and re-run the request each time; for the resource variant, allow providing
on_create
,on_update
, andon_delete
API endpoints/requests that get run at their respective points in the lifecycle.New or Affected Resource(s)
Potential Terraform Configuration
An example of how you would use this to add S3 replication after a bucket has been created (a workaround for issue #749):
In this example,
on_create
andon_update
would be the same since PutBucketReplication is idempotent.For a different use case, such as Kinesis Firehose CreateDeliveryStream, the
on_create
,on_update
, andon_delete
blocks might use the CreateDeliveryStream, UpdateDestination, and DeleteDeliveryStream actions, respectively.The resource variant would support multiple
on_create
,on_update
, andon_delete
blocks to allow for multiple actions to be taken at each stage in the lifecycle.The text was updated successfully, but these errors were encountered: