https://github.com/ega4432/cloudfront-functions-sample
This is a sample repository of CloudFront Functions.
https://github.com/ega4432/cloudfront-functions-sample
aws cloudfront cloudfront-fuctions hcl s3 terraform
Last synced: 3 months ago
JSON representation
This is a sample repository of CloudFront Functions.
- Host: GitHub
- URL: https://github.com/ega4432/cloudfront-functions-sample
- Owner: ega4432
- License: mit
- Created: 2021-05-22T10:25:07.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-23T05:55:10.000Z (about 5 years ago)
- Last Synced: 2025-07-05T14:48:52.589Z (about 1 year ago)
- Topics: aws, cloudfront, cloudfront-fuctions, hcl, s3, terraform
- Language: HCL
- Homepage: https://zenn.dev/ysmtegsr/articles/d4eb3e8493b7a5ccd427
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.ja.md
- License: LICENSE
Awesome Lists containing this project
README
# CloudFront Functions Sample



[ [英語](https://github.com/ysmtegsr/cloudfront-functions-sample) | 日本語 ]
CloudFront Functions の検証用サンプルリポジトリです。Terraform で構築しました。
ref. [Amazon CloudFront が軽量エッジコンピューティング機能である CloudFront Functions を発表](https://aws.amazon.com/jp/about-aws/whats-new/2021/05/cloudfront-functions/)
## セットアップ
下記の CLI を使います。
- AWS CLI
- Terraform CLI via tfenv
Terraform の定数ファイルを作成します。
```sh
$ vim terraform.tfvars
```
```terraform.tfvars
aws_access_key_id = "XXXXXXXXXXXXXXXXXX"
aws_secret_access_key = "YYYYYYYYYYYYYYYYYYYYYYYYY"
region = "ap-northeast-1"
bucket_name = "cloudfront-functions-sample"
```
## 構築手順
```sh
# 各モジュールをインポート
$ terraform init
# 事前確認
$ terraform plan --var-file=terraform.tfvars
# デプロイ実行
$ terraform apply --var-file=terraform.tfvars
```
## S3 にコンテンツをアップロード
AWS CLI を使って静的コンテンツをアップロードします。
```sh
$ aws s3 cp ./src s3:///dist/ --recursive
```
## リソースを削除
```sh
# S3 のコンテンツを全削除
$ aws s3 rm s3:/// --recursive
# 事前確認
$ terraform plan --var-file=terraform.tfvar --destroy
# 削除
$ terraform destroy --var-file=terraform.tfvar
```