File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ provider "aws" {
3
3
}
4
4
5
5
provider "random" {}
6
+ data "aws_caller_identity" "current" {}
6
7
7
8
locals {
8
9
definition_template = << EOF
@@ -203,6 +204,10 @@ locals {
203
204
}
204
205
}
205
206
EOF
207
+ tags = {
208
+ Name = " payments"
209
+ Environment = " PROD"
210
+ }
206
211
}
207
212
208
213
@@ -369,6 +374,20 @@ module "fx_lambda" {
369
374
370
375
}
371
376
377
+ module "kms" {
378
+ source = " terraform-aws-modules/kms/aws"
379
+ version = " ~> 1.0"
380
+ description = " Securing SFN with KMS Keys"
381
+
382
+ # Aliases
383
+ aliases = [" realtimepayments" ]
384
+ aliases_use_name_prefix = true
385
+
386
+ key_owners = [data . aws_caller_identity . current . arn ]
387
+
388
+ tags = local. tags
389
+ }
390
+
372
391
module "sfn" {
373
392
source = " ./stepfunction"
374
393
@@ -379,6 +398,12 @@ module "sfn" {
379
398
definition = local. definition_template
380
399
publish = true
381
400
401
+ encryption_configuration = {
402
+ type = " CUSTOMER_MANAGED_KMS_KEY"
403
+ kms_key_id = module.kms.key_arn
404
+ kms_data_key_reuse_period_seconds = 600
405
+ }
406
+
382
407
logging_configuration = {
383
408
include_execution_data = true
384
409
level = " ALL"
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ resource "aws_sfn_state_machine" "this" {
21
21
definition = var. definition
22
22
publish = var. publish
23
23
24
+ dynamic "encryption_configuration" {
25
+ for_each = length (var. encryption_configuration ) > 0 ? [var . encryption_configuration ] : []
26
+
27
+ content {
28
+ type = encryption_configuration. value . type
29
+ kms_key_id = try (encryption_configuration. value . kms_key_id , null )
30
+ kms_data_key_reuse_period_seconds = try (encryption_configuration. value . kms_data_key_reuse_period_seconds , null )
31
+ }
32
+ }
33
+
24
34
dynamic "logging_configuration" {
25
35
for_each = local. enable_logging ? [true ] : []
26
36
@@ -313,4 +323,4 @@ resource "aws_cloudwatch_log_group" "sfn" {
313
323
kms_key_id = var. cloudwatch_log_group_kms_key_id
314
324
315
325
tags = merge (var. tags , var. cloudwatch_log_group_tags )
316
- }
326
+ }
Original file line number Diff line number Diff line change @@ -73,6 +73,12 @@ variable "publish" {
73
73
default = false
74
74
}
75
75
76
+ variable "encryption_configuration" {
77
+ description = " Newly added encryption configuration which is used to encrypt data in the State Machine."
78
+ type = any
79
+ default = {}
80
+ }
81
+
76
82
# ################
77
83
# CloudWatch Logs
78
84
# ################
@@ -256,4 +262,4 @@ variable "policy_statements" {
256
262
description = " Map of dynamic policy statements to attach to IAM role"
257
263
type = any
258
264
default = {}
259
- }
265
+ }
You can’t perform that action at this time.
0 commit comments