Skip to content

Commit

Permalink
move to tf 14; sensitive vars
Browse files Browse the repository at this point in the history
  • Loading branch information
swhite24 committed Mar 3, 2021
1 parent af1fbb3 commit 5ddec47
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 18 deletions.
40 changes: 40 additions & 0 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 21 additions & 15 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ resource aws_lambda_function cbpro_buy {

environment {
variables = {
foo = "bar"
CBPRO_BUY_KEY = var.cbpro_key
CBPRO_BUY_PASSPHRASE = var.cbpro_passphrase
CBPRO_BUY_SECRET = var.cbpro_secret
CBPRO_BUY_CURRENCY = var.currency
CBPRO_BUY_PRODUCT = var.product
CBPRO_BUY_AMOUNT = var.amount
CBPRO_BUY_AUTODEPOSIT = var.auto_deposit
}
}
}
Expand Down Expand Up @@ -67,19 +73,19 @@ resource aws_iam_role_policy_attachment lambda_logs {
policy_arn = aws_iam_policy.lambda_logging.arn
}

# resource aws_cloudwatch_event_rule event_rule {
# schedule_expression = var.lambda_schedule_expression
# }
resource aws_cloudwatch_event_rule event_rule {
schedule_expression = var.lambda_schedule_expression
}

# resource aws_cloudwatch_event_target event_target {
# rule = aws_cloudwatch_event_rule.event_rule.name
# arn = aws_lambda_function.cbpro_buy.arn
# }
resource aws_cloudwatch_event_target event_target {
rule = aws_cloudwatch_event_rule.event_rule.name
arn = aws_lambda_function.cbpro_buy.arn
}

# resource aws_lambda_permission cloudwatch_permission {
# statement_id = "AllowExecutionFromCloudWatch"
# action = "lambda:InvokeFunction"
# function_name = var.function_name
# principal = "events.amazonaws.com"
# source_arn = aws_cloudwatch_event_rule.event_rule.arn
# }
resource aws_lambda_permission cloudwatch_permission {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = var.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.event_rule.arn
}
19 changes: 18 additions & 1 deletion terraform/var.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
variable function_name { default = "cbpro-buy-weekly" }
variable lambda_schedule_expression { default = "cron(0 5 ? * 5 *)"}
variable lambda_schedule_expression { default = "cron(0 5 ? * 5 *)" }
variable executable { default = "cbpro-buy-lambda" }
variable archive { default = "cbpro-buy-lambda.zip" }
# set to 1 or null
variable auto_deposit { default = 1 }
variable amount { default = 10 }
variable currency { default = "USD" }
variable product { default = "BTC" }
variable cbpro_key {
type = string
sensitive = true
}
variable cbpro_passphrase {
type = string
sensitive = true
}
variable cbpro_secret {
type = string
sensitive = true
}
4 changes: 2 additions & 2 deletions terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ terraform {
version = "~> 3.30.0"
}
archive = {
souce = "hashicorp/archive"
source = "hashicorp/archive"
version = "~> 2.1.0"
}
}
required_version = "~> 0.13.6"
required_version = "~> 0.14.7"
}

0 comments on commit 5ddec47

Please sign in to comment.