Skip to content

Commit b5a0793

Browse files
committed
docs: add standalone distribution example
1 parent 32c046c commit b5a0793

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ terraform.rc
3838

3939
# Ignore IDE
4040
.idea/
41+
42+
# Ignore Terraform locks in examples folder
43+
examples/**/*.lock.hcl
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
resource "aws_cloudfront_distribution" "fpjs_cloudfront_distribution" {
2+
comment = "Fingerprint proxy integration distribution (created via Terraform)"
3+
4+
origin {
5+
domain_name = module.fingerprint_cloudfront_integration.fpjs_origin_name
6+
origin_id = module.fingerprint_cloudfront_integration.fpjs_origin_id
7+
custom_origin_config {
8+
origin_protocol_policy = "https-only"
9+
http_port = 80
10+
https_port = 443
11+
origin_ssl_protocols = ["TLSv1.2"]
12+
}
13+
custom_header {
14+
name = "FPJS_SECRET_NAME"
15+
value = module.fingerprint_cloudfront_integration.fpjs_secret_manager_arn
16+
}
17+
}
18+
19+
enabled = true
20+
21+
http_version = "http1.1"
22+
23+
price_class = "PriceClass_100"
24+
25+
default_cache_behavior {
26+
allowed_methods = ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
27+
cached_methods = ["GET", "HEAD"]
28+
cache_policy_id = module.fingerprint_cloudfront_integration.fpjs_cache_policy_id
29+
origin_request_policy_id = module.fingerprint_cloudfront_integration.fpjs_origin_request_policy_id
30+
target_origin_id = module.fingerprint_cloudfront_integration.fpjs_origin_id
31+
viewer_protocol_policy = "https-only"
32+
compress = true
33+
34+
lambda_function_association {
35+
event_type = "origin-request"
36+
lambda_arn = module.fingerprint_cloudfront_integration.fpjs_proxy_lambda_arn
37+
include_body = true
38+
}
39+
}
40+
41+
42+
43+
restrictions {
44+
geo_restriction {
45+
restriction_type = "none"
46+
}
47+
}
48+
49+
aliases = ["${var.subdomain}.${var.root_domain}"]
50+
viewer_certificate {
51+
acm_certificate_arn = "arn:aws:acm:us-east-1:013357491684:certificate/c3ffee8c-071b-4ff8-bec2-e222eff602bc"
52+
ssl_support_method = "sni-only"
53+
}
54+
55+
# If don't want to serve the distribution from a subdomain for now, use the default certificate instead
56+
# (comment out `viewer_certificate` and `aliases` above and use the `viewer_certificate` below)
57+
58+
# viewer_certificate {
59+
# cloudfront_default_certificate = true
60+
# }
61+
}
62+
63+
# You can make the distribution avaialable on a subdomain of your website
64+
# (comment this out if you don't want to do that for now)
65+
resource "aws_route53_record" "cloudfront_terraform_new_distribution_record" {
66+
zone_id = var.domain_zone_id
67+
name = "${var.subdomain}.${var.root_domain}"
68+
type = "CNAME"
69+
ttl = 300
70+
records = [aws_cloudfront_distribution.fpjs_cloudfront_distribution.domain_name]
71+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module "fingerprint_cloudfront_integration" {
2+
source = "[email protected]:fingerprintjs/terraform-aws-fingerprint-cloudfront-proxy-integration.git"
3+
4+
fpjs_agent_download_path = var.fpjs_agent_download_path
5+
fpjs_get_result_path = var.fpjs_get_result_path
6+
fpjs_shared_secret = var.fpjs_shared_secret
7+
}
8+
9+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.57"
6+
}
7+
}
8+
9+
required_version = ">= 1.2.0"
10+
}
11+
12+
provider "aws" {
13+
region = "us-east-1"
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
variable "fpjs_shared_secret" {
2+
description = "The proxy secret for the Fingerprint proxy integration"
3+
type = string
4+
}
5+
6+
variable "fpjs_agent_download_path" {
7+
description = "The Fingerprint agent download will be proxied through this path"
8+
type = string
9+
}
10+
11+
variable "fpjs_get_result_path" {
12+
description = "The Fingerprint identification request will be proxied through this path"
13+
type = string
14+
}
15+
16+
variable "subdomain" {
17+
description = "The subdomain for the CloudFront distribution"
18+
type = string
19+
# default = "metrics"
20+
}
21+
22+
variable "root_domain" {
23+
description = "The root domain for the CloudFront distribution"
24+
type = string
25+
# default = "yourwebsite.com"
26+
}
27+
28+
variable "domain_zone_id" {
29+
description = "Zone ID of the domain for the CloudFront distribution"
30+
type = string
31+
}

0 commit comments

Comments
 (0)