Skip to content

Commit

Permalink
Added dynamodb infra changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Jun 13, 2023
1 parent 1f13a98 commit 9d6b344
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
24 changes: 13 additions & 11 deletions config/initializers/rswag_api.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# frozen_string_literal: true

Rswag::Api.configure do |c|
# Specify a root folder where Swagger JSON files are located
# This is used by the Swagger middleware to serve requests for API descriptions
# NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
# that it's configured to generate files in the same folder
c.swagger_root = "#{Rails.root}/swagger"
unless Rails.env.production?
Rswag::Api.configure do |c|
# Specify a root folder where Swagger JSON files are located
# This is used by the Swagger middleware to serve requests for API descriptions
# NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
# that it's configured to generate files in the same folder
c.swagger_root = "#{Rails.root}/swagger"

# Inject a lambda function to alter the returned Swagger prior to serialization
# The function will have access to the rack env for the current request
# For example, you could leverage this to dynamically assign the "host" property
#
# c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
# Inject a lambda function to alter the returned Swagger prior to serialization
# The function will have access to the rack env for the current request
# For example, you could leverage this to dynamically assign the "host" property
#
# c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
end
end
3 changes: 2 additions & 1 deletion infra/handler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ data "aws_iam_policy_document" "task_policy" {
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
]
resources = [var.shared_resources.dynamo_registration_table]
resources = ["${var.shared_resources.dynamo_registration_table}/*"]
}
statement {
effect = "Allow"
Expand Down
8 changes: 6 additions & 2 deletions infra/shared/dynamodb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ resource "aws_dynamodb_table" "registrations" {
}
global_secondary_index {
hash_key = "competition_id"
name = "competition_id"
name = "registrations_index_competition_id"
projection_type = "ALL"
write_capacity = 5
read_capacity = 5
}

global_secondary_index {
hash_key = "user_id"
name = "user_id"
name = "registrations_index_user_id"
projection_type = "ALL"
write_capacity = 5
read_capacity = 5
}

lifecycle {
Expand Down
8 changes: 6 additions & 2 deletions infra/staging/dynamodb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ resource "aws_dynamodb_table" "registrations" {
}
global_secondary_index {
hash_key = "competition_id"
name = "competition_id"
name = "registrations-staging_index_competition_id"
projection_type = "ALL"
write_capacity = 5
read_capacity = 5
}

global_secondary_index {
hash_key = "user_id"
name = "user_id"
name = "registrations-staging_index_user_id"
projection_type = "ALL"
write_capacity = 5
read_capacity = 5
}

lifecycle {
Expand Down
3 changes: 2 additions & 1 deletion infra/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ data "aws_iam_policy_document" "task_policy" {
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
]
resources = [aws_dynamodb_table.registrations.arn]
resources = ["${aws_dynamodb_table.registrations.arn}/*"]
}
statement {
effect = "Allow"
Expand Down
3 changes: 2 additions & 1 deletion infra/worker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ data "aws_iam_policy_document" "task_policy" {
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
]
resources = [var.shared_resources.dynamo_registration_table]
resources = ["${var.shared_resources.dynamo_registration_table}/*"]
}
statement {
effect = "Allow"
Expand Down

0 comments on commit 9d6b344

Please sign in to comment.