PR is here
Shipped in Provider version 4.17.0.
Adding an ability for using AWS Secrets Manager secret resource as input for AWS DMS Endpoint with Redshift
engine.
Please note, that AWS Redshift database can be used only as target
for AWS DMS endpoint.
It will allow us to not store Redshift DB credentials in .tf
files but rather read the creds from a secured source.
AWS API and userguide docs refs:
Lessons learned
Look around and try to find some ways to make a code more readable
Don’t be thinking only about the place in code that is directly related to your feature or enhancement.
Look around, there might be some places where you can improve code structure and readability. For example, you might notice as some code blocks are repeated more than one time (breaking the DRY principle). That’s a good chance to introduce a small function that will do the same but without code duplications. Then just call this function where needed. It can significantly reduce the amount of the code.
For example, there was the following code repeated 14 times within the same file:
We have some input
object and this code block just sets some generic parameters.
New function has been introduced:
The same idea is also true for the Acceptance tests. You might see that some of Terraform code snippets are just copied and pasted for different test cases.
For example:
As you can see, all data
resources might be common for different aws_dms_endpoint
resources.
There are only two attributes that change:
aws_dms_endpoint.endoint_id
aws_dms_endpoint.engine_name
- this will differ for different DB engines (mariadb
,redshift
,mysql
and so on)
You can introduce a new simple function that renders this common Terraform code and then just call this base function where needed:
And then just call it where needed:
Pass *schema.ResourceData
parameters to functions as a first argument
It’s better to pass a parameter of *schema.ResourceData
type to function on the first place:
It does not make any change to code logic but rather it’s some kind of guideline or best practice.
Leave a comment