Skip to content

Instantly share code, notes, and snippets.

@nivleshc
nivleshc / blog-photo-location-map-api_gateway-05.tf
Created March 23, 2025 13:27
This gist contains code from the file api_gateway.tf which is part of the blog-photo-location-map repository.
resource "aws_api_gateway_integration" "fetch_object" {
rest_api_id = aws_api_gateway_rest_api.photo_location_map.id
resource_id = aws_api_gateway_resource.fetch_object.id
http_method = aws_api_gateway_method.fetch_object_get.http_method
integration_http_method = "POST"
type = "AWS_PROXY"
uri = aws_lambda_function.fetch_object_lambda.invoke_arn
}
@nivleshc
nivleshc / blog-photo-location-map-api_gateway-04.tf
Created March 23, 2025 13:24
This gist contains code from the file api_gateway.tf which is part of the blog-photo-location-map repository.
resource "aws_api_gateway_method" "fetch_object_get" {
rest_api_id = aws_api_gateway_rest_api.photo_location_map.id
resource_id = aws_api_gateway_resource.fetch_object.id
http_method = "GET"
authorization = "NONE"
}
@nivleshc
nivleshc / blog-photo-location-map-api_gateway-03.tf
Created March 23, 2025 13:21
This gist contains code from the file api_gateway.tf which is part of the blog-photo-location-map repository.
resource "aws_api_gateway_resource" "fetch_object" {
rest_api_id = aws_api_gateway_rest_api.photo_location_map.id
parent_id = aws_api_gateway_rest_api.photo_location_map.root_resource_id
path_part = local.api_gateway_fetch_object_path
}
@nivleshc
nivleshc / blog-photo-location-map-api_gateway-02.tf
Created March 23, 2025 13:17
This gist contains code from the file api_gateway.tf which is part of the blog-photo-location-map repository.
resource "aws_lambda_permission" "apigw_invoke_fetch_object_lambda" {
statement_id = "AllowAPIGatewayInvoke"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.fetch_object_lambda.function_name
principal = "apigateway.amazonaws.com"
source_arn = "${aws_api_gateway_rest_api.photo_location_map.execution_arn}/*/*"
}
@nivleshc
nivleshc / blog-photo-location-map-api_gateway-01.tf
Created March 23, 2025 13:11
This gist contains code from the file api_gateway.tf which is part of the blog-photo-location-map repository.
resource "aws_api_gateway_rest_api" "photo_location_map" {
name = "${local.api_gateway_rest_api_name_prefix}-api-gw"
description = "API Gateway to front lambdas used to plot photo locations on a map"
endpoint_configuration {
types = ["REGIONAL"]
}
}
@nivleshc
nivleshc / blog-photo-location-map-cognito-04.tf
Created March 23, 2025 03:44
This gist contains code from the file cognito.tf which is part of the blog-photo-location-map repository.
output "cognito_ui_url" {
value = "https://${aws_cognito_user_pool.user_pool.domain}.auth.${local.region}.amazoncognito.com/login?client_id=${aws_cognito_user_pool_client.user_pool_client.id}&response_type=code&scope=openid&redirect_uri=${tolist(aws_cognito_user_pool_client.user_pool_client.callback_urls)[0]}"
depends_on = [aws_cognito_user_pool.user_pool]
}
output "cognito_user_pool_id" {
value = aws_cognito_user_pool.user_pool.id
}
output "cognito_user_pool_client_id" {
@nivleshc
nivleshc / blog-photo-location-map-cognito-03.tf
Created March 23, 2025 03:36
This gist contains code from the file cognito.tf which is part of the blog-photo-location-map repository.
resource "aws_cognito_user_pool_domain" "user_pool_domain" {
domain = local.cognito_user_pool_domain # Must be globally unique
user_pool_id = aws_cognito_user_pool.user_pool.id
}
@nivleshc
nivleshc / blog-photo-location-map-cognito-02.tf
Created March 23, 2025 03:29
This gist contains code from the file cognito.tf which is part of the blog-photo-location-map repository.
resource "aws_cognito_user_pool_client" "user_pool_client" {
name = local.cognito_user_pool_client_name
user_pool_id = aws_cognito_user_pool.user_pool.id
supported_identity_providers = ["COGNITO"]
# Do not generate a client secret for browser-based apps
generate_secret = false
# Allowed OAuth flows and scopes for the hosted UI.
allowed_oauth_flows_user_pool_client = true
@nivleshc
nivleshc / blog-photo-location-map-cognito-01.tf
Created March 23, 2025 03:18
This gist contains code from the file cognito.tf which is part of the blog-photo-location-map repository.
resource "aws_cognito_user_pool" "user_pool" {
name = local.cognito_user_pool_name
# Customize password policy, MFA, etc., as needed
password_policy {
minimum_length = local.cognito_password_policy.minimum_length
require_uppercase = local.cognito_password_policy.require_uppercase
require_lowercase = local.cognito_password_policy.require_lowercase
require_numbers = local.cognito_password_policy.require_numbers
require_symbols = local.cognito_password_policy.require_symbols
@nivleshc
nivleshc / blog-amazon-s3-filesystem-amazon-eks-helm-values.yaml
Created August 21, 2024 10:10
This gist contains code from the helm/s3-csi-demo/values.yaml file which is part of the blog-amazon-s3-filesystem-for-amazon-eks-cluster repository.
storageClass:
name: s3-storageclass
provisioner: s3.csi.aws.com # Provisioner for AWS S3
parameters:
type: standard
persistentVolume:
name: s3-pv
capacity:
storageSize: 5Gi