Skip to content

Latest commit

 

History

History
67 lines (44 loc) · 1.48 KB

README.md

File metadata and controls

67 lines (44 loc) · 1.48 KB

CloudFront Functions Sample

GitHub

[ English | Japanese ]

This is a sample repository of CloudFront Functions.Built with HCL ( Terraform ).

ref. Amazon CloudFront announces CloudFront Functions, a lightweight edge compute capability

Setup

Prepare CLIs.

  • AWS CLI
  • Terraform CLI via tfenv

Create terraform var file.

$ vim terraform.tfvars
aws_access_key_id     = "XXXXXXXXXXXXXXXXXX"
aws_secret_access_key = "YYYYYYYYYYYYYYYYYYYYYYYYY"
region                = "ap-northeast-1"
bucket_name           = "cloudfront-functions-sample"

How to Use

# import modules
$ terraform init

# Dry run
$ terraform plan --var-file=terraform.tfvars

# Deploy
$ terraform apply --var-file=terraform.tfvars

Upload to S3

Static contents upload via AWS CLI.

$ aws s3 cp ./src s3://<BUCKET NAME>/dist/ --recursive

Destroy resources

# Delete static contents from S3 bucket
$ aws s3 rm s3://<BUCKET NAME>/ --recursive

# Dry run
$ terraform plan --var-file=terraform.tfvar --destroy

# Destroy
$ terraform destroy --var-file=terraform.tfvar