-
Notifications
You must be signed in to change notification settings - Fork 143
Add Fastly Object Storage guide to documentation. #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b30dba1
Add Fastly Object Storage guide to documentation.
kpfleming b394203
Merge branch 'main' into add-fos-guide
kpfleming ab953a7
Apply suggestions from code review
kpfleming 54cc991
Update generated docs.
kpfleming ca280d6
Merge branch 'main' into add-fos-guide
kpfleming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
page_title: Managing content in Fastly Object Storage | ||
subcategory: "Guides" | ||
--- | ||
# Managing content in Fastly Object Storage | ||
|
||
Content in Fastly Object Storage (buckets and objects) can be managed | ||
using a combination of this provider (Fastly) and the Amazon Web | ||
Services (AWS) provider, since Fastly Object Storage provides an AWS | ||
S3-compatible API. | ||
|
||
## Example Configuration | ||
|
||
Two HCL files are required. The first, `main.tf`: | ||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
fastly = { | ||
source = "fastly/fastly" | ||
version = "~> 7.1.0" | ||
} | ||
} | ||
} | ||
|
||
resource "fastly_object_storage_access_keys" "main" { | ||
description = "FOS Key" | ||
permission = "read-write-admin" | ||
} | ||
|
||
module "fos" { | ||
source = "./fos" | ||
access_key_id = fastly_object_storage_access_keys.main.id | ||
secret_key = fastly_object_storage_access_keys.main.secret_key | ||
} | ||
``` | ||
|
||
The second will need to be placed in a directory named `fos`, and | ||
named `fos/main.tf`: | ||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "= 6.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
access_key = var.access_key_id | ||
secret_key = var.secret_key | ||
region = "us-east" | ||
|
||
s3_use_path_style = true | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
skip_region_validation = true | ||
skip_requesting_account_id = true | ||
|
||
endpoints { | ||
s3 = "https://us-east.object.fastlystorage.app" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "main" { | ||
bucket = "my-test-bucket-123" | ||
|
||
# Fastly object storage uses different region names | ||
lifecycle { | ||
ignore_changes = [region] | ||
} | ||
} | ||
|
||
``` | ||
|
||
Note: This example uses the `us-east` region of Fastly Object Storage; | ||
if you wish to use a different region, ensure that the proper region | ||
code is included in the `endpoints` block above. | ||
|
||
## Getting Started | ||
|
||
With the example files in place, you'll need to initialize Terraform | ||
and obtain Fastly Object Storage credentials. | ||
|
||
```bash | ||
export FASTLY_API_KEY=<your Fastly API key here> | ||
terraform init | ||
terraform apply -target=fastly_object_storage_access_keys.main | ||
``` | ||
|
||
Note: Terraform will issue a warning because the `-target` option is | ||
used. This usage of that option is safe. | ||
|
||
This step will connect to the Fastly API using the Fastly Terraform | ||
provider and obtain a set of Fastly Object Storage credentials. Those | ||
credentials will be stored in the Terraform state files (or other | ||
state storage), they will not be displayed. | ||
|
||
This initial step is necessary because the credentials are required by | ||
the AWS Terraform provider, and if Terraform attempts to apply the | ||
entire configuration the AWS provider will report an error because the | ||
credentials are missing. | ||
|
||
## Completing the Process | ||
|
||
With the credentials obtained, a normal Terraform `apply` step can be | ||
used to create the remaining infrastructure; in this case a bucket in | ||
Fastly Object Storage named `my-test-bucket-123`. Terraform will pass | ||
the Fastly Object Storage credentials to the AWS Terraform provider so | ||
that it can use them to authenticate its API interactions with the | ||
Fastly Object Storage system. | ||
|
||
```bash | ||
terraform apply | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
page_title: Managing content in Fastly Object Storage | ||
subcategory: "Guides" | ||
--- | ||
# Managing content in Fastly Object Storage | ||
|
||
Content in Fastly Object Storage (buckets and objects) can be managed | ||
using a combination of this provider (Fastly) and the Amazon Web | ||
Services (AWS) provider, since Fastly Object Storage provides an AWS | ||
S3-compatible API. | ||
|
||
## Example Configuration | ||
|
||
Two HCL files are required. The first, `main.tf`: | ||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
fastly = { | ||
source = "fastly/fastly" | ||
version = "~> 7.1.0" | ||
} | ||
} | ||
} | ||
|
||
resource "fastly_object_storage_access_keys" "main" { | ||
description = "FOS Key" | ||
permission = "read-write-admin" | ||
} | ||
|
||
module "fos" { | ||
source = "./fos" | ||
access_key_id = fastly_object_storage_access_keys.main.id | ||
secret_key = fastly_object_storage_access_keys.main.secret_key | ||
} | ||
``` | ||
|
||
The second will need to be placed in a directory named `fos`, and | ||
named `fos/main.tf`: | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "= 6.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
access_key = var.access_key_id | ||
secret_key = var.secret_key | ||
region = "us-east" | ||
|
||
s3_use_path_style = true | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
skip_region_validation = true | ||
skip_requesting_account_id = true | ||
|
||
endpoints { | ||
s3 = "https://us-east.object.fastlystorage.app" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "main" { | ||
bucket = "my-test-bucket-123" | ||
|
||
# Fastly object storage uses different region names | ||
lifecycle { | ||
ignore_changes = [region] | ||
} | ||
} | ||
|
||
``` | ||
|
||
Note: This example uses the `us-east` region of Fastly Object Storage; | ||
if you wish to use a different region, ensure that the proper region | ||
code is included in the `endpoints` block above. | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Getting Started | ||
|
||
With the example files in place, you'll need to initialize Terraform | ||
and obtain Fastly Object Storage credentials. | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```bash | ||
export FASTLY_API_KEY=<your Fastly API key here> | ||
terraform init | ||
terraform apply -target=fastly_object_storage_access_keys.main | ||
``` | ||
|
||
Note: Terraform will issue a warning because the `-target` option is | ||
used. This usage of that option is safe. | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
This step will connect to the Fastly API using the Fastly Terraform | ||
provider and obtain a set of Fastly Object Storage credentials. Those | ||
credentials will be stored in the Terraform state files (or other | ||
state storage), they will not be displayed. | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
This initial step is necessary because the credentials are required by | ||
the AWS Terraform provider, and if Terraform attempts to apply the | ||
entire configuration the AWS provider will report an error because the | ||
credentials are missing. | ||
kpfleming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Completing the Process | ||
|
||
With the credentials obtained, a normal Terraform `apply` step can be | ||
used to create the remaining infrastructure; in this case a bucket in | ||
Fastly Object Storage named `my-test-bucket-123`. Terraform will pass | ||
the Fastly Object Storage credentials to the AWS Terraform provider so | ||
that it can use them to authenticate its API interactions with the | ||
Fastly Object Storage system. | ||
kpfleming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```bash | ||
terraform apply | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.