Skip to content

Commit 6063197

Browse files
authored
feat: add region and service to AWS destination auth (#116)
* wip: add region and service to AWS destination auth * fix: open API spec from source controls should be used over live version * chore: go generate
1 parent eb8a85d commit 6063197

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

docs/data-sources/destination.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ Whether the API key should be sent as a header or a query parameter
7373
Read-Only:
7474

7575
- `access_key_id` (String, Sensitive) AWS access key id
76+
- `region` (String) AWS region
7677
- `secret_access_key` (String, Sensitive) AWS secret access key
78+
- `service` (String) AWS service
7779

7880

7981
<a id="nestedatt--auth_method--basic_auth"></a>

docs/resources/destination.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ Required:
9494
- `access_key_id` (String, Sensitive) AWS access key id
9595
- `secret_access_key` (String, Sensitive) AWS secret access key
9696

97+
Optional:
98+
99+
- `region` (String) AWS region
100+
- `service` (String) AWS service
101+
97102

98103
<a id="nestedatt--auth_method--basic_auth"></a>
99104
### Nested Schema for `auth_method.basic_auth`

examples/full/main.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ variable "HEADER_FILTER_VALUES" {
99
terraform {
1010
required_providers {
1111
hookdeck = {
12-
source = "hookdeck/hookdeck"
12+
source = "hookdeck/hookdeck"
13+
version = "0.5.0-beta.1"
1314
}
1415
}
1516
}
@@ -65,6 +66,19 @@ resource "hookdeck_destination" "second_destination" {
6566
}
6667
}
6768

69+
resource "hookdeck_destination" "aws_destination" {
70+
name = "aws_destination"
71+
url = "https://mock.hookdeck.com"
72+
auth_method = {
73+
aws_signature = {
74+
access_key_id = "some-access"
75+
secret_access_key = "some-secret"
76+
region = "us-west-2"
77+
service = "lambda"
78+
}
79+
}
80+
}
81+
6882
resource "hookdeck_connection" "first_connection" {
6983
source_id = hookdeck_source.first_source.id
7084
destination_id = hookdeck_destination.first_destination.id

internal/codegen/codegen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/getkin/kin-openapi/openapi3"
1111
)
1212

13-
const hookdeckOpenAPISchemaURI = "https://api.hookdeck.com/latest/openapi"
13+
const hookdeckOpenAPISchemaURI = "https://raw.githubusercontent.com/hookdeck/hookdeck-api-schema/refs/heads/main/openapi.json"
1414

1515
func RunCodeGen() error {
1616
fmt.Println("generating Hookdeck source verifications")

internal/provider/destination/authentication_awssignature.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
type awsSignatureAuthenticationMethodModel struct {
1111
AccessKeyID types.String `tfsdk:"access_key_id"`
1212
SecretAccessKey types.String `tfsdk:"secret_access_key"`
13+
Region types.String `tfsdk:"region"`
14+
Service types.String `tfsdk:"service"`
1315
}
1416

1517
type awsSignatureAuthenticationMethod struct {
@@ -33,6 +35,16 @@ func (*awsSignatureAuthenticationMethod) schema() schema.Attribute {
3335
Sensitive: true,
3436
Description: `AWS secret access key`,
3537
},
38+
"region": schema.StringAttribute{
39+
Optional: true,
40+
Sensitive: false,
41+
Description: `AWS region`,
42+
},
43+
"service": schema.StringAttribute{
44+
Optional: true,
45+
Sensitive: false,
46+
Description: `AWS service`,
47+
},
3648
},
3749
Description: `AWS Signature`,
3850
}
@@ -42,6 +54,8 @@ func awsSignatureAuthenticationMethodAttrTypesMap() map[string]attr.Type {
4254
return map[string]attr.Type{
4355
"access_key_id": types.StringType,
4456
"secret_access_key": types.StringType,
57+
"region": types.StringType,
58+
"service": types.StringType,
4559
}
4660
}
4761

@@ -61,6 +75,12 @@ func (awsSignatureAuthenticationMethod) refresh(m *destinationResourceModel, des
6175
m.AuthMethod.AWSSignature = &awsSignatureAuthenticationMethodModel{}
6276
m.AuthMethod.AWSSignature.AccessKeyID = types.StringValue(destination.AuthMethod.AwsSignature.Config.AccessKeyId)
6377
m.AuthMethod.AWSSignature.SecretAccessKey = types.StringValue(destination.AuthMethod.AwsSignature.Config.SecretAccessKey)
78+
if destination.AuthMethod.AwsSignature.Config.Region != nil {
79+
m.AuthMethod.AWSSignature.Region = types.StringValue(*destination.AuthMethod.AwsSignature.Config.Region)
80+
}
81+
if destination.AuthMethod.AwsSignature.Config.Service != nil {
82+
m.AuthMethod.AWSSignature.Service = types.StringValue(*destination.AuthMethod.AwsSignature.Config.Service)
83+
}
6484
}
6585

6686
func (awsSignatureAuthenticationMethod) toPayload(method *destinationAuthMethodConfig) *hookdeck.DestinationAuthMethodConfig {
@@ -72,6 +92,8 @@ func (awsSignatureAuthenticationMethod) toPayload(method *destinationAuthMethodC
7292
Config: &hookdeck.DestinationAuthMethodAwsSignatureConfig{
7393
AccessKeyId: method.AWSSignature.AccessKeyID.ValueString(),
7494
SecretAccessKey: method.AWSSignature.SecretAccessKey.ValueString(),
95+
Region: method.AWSSignature.Region.ValueStringPointer(),
96+
Service: method.AWSSignature.Service.ValueStringPointer(),
7597
},
7698
})
7799
}

0 commit comments

Comments
 (0)