Skip to content
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

option to deploy to website bucket #87

Merged
merged 3 commits into from Feb 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion README.md
Expand Up @@ -283,6 +283,26 @@ Available targets:
|------|---------|
| aws | >= 2.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| codebuild | cloudposse/codebuild/aws | 0.32.0 |
| this | cloudposse/label/null | 0.24.1 |

## Resources

| Name |
|------|
| [aws_caller_identity](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/caller_identity) |
| [aws_codepipeline](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/codepipeline) |
| [aws_iam_policy](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_policy) |
| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/iam_policy_document) |
| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_role) |
| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_role_policy_attachment) |
| [aws_region](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/region) |
| [aws_s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/s3_bucket) |

## Inputs

| Name | Description | Type | Default | Required |
Expand Down Expand Up @@ -324,6 +344,7 @@ Available targets:
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
| versioning\_enabled | A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket | `bool` | `true` | no |
| website\_bucket\_name | Name of the S3 bucket where the website will be deployed | `string` | `""` | no |

## Outputs

Expand All @@ -338,7 +359,6 @@ Available targets:
| codebuild\_role\_id | CodeBuild IAM Role ID |
| codepipeline\_arn | CodePipeline ARN |
| codepipeline\_id | CodePipeline ID |

<!-- markdownlint-restore -->


Expand Down
22 changes: 21 additions & 1 deletion docs/terraform.md
Expand Up @@ -12,6 +12,26 @@
|------|---------|
| aws | >= 2.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| codebuild | cloudposse/codebuild/aws | 0.32.0 |
| this | cloudposse/label/null | 0.24.1 |

## Resources

| Name |
|------|
| [aws_caller_identity](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/caller_identity) |
| [aws_codepipeline](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/codepipeline) |
| [aws_iam_policy](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_policy) |
| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/iam_policy_document) |
| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_role) |
| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/iam_role_policy_attachment) |
| [aws_region](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/data-sources/region) |
| [aws_s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/2.0/docs/resources/s3_bucket) |

## Inputs

| Name | Description | Type | Default | Required |
Expand Down Expand Up @@ -53,6 +73,7 @@
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
| versioning\_enabled | A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket | `bool` | `true` | no |
| website\_bucket\_name | Name of the S3 bucket where the website will be deployed | `string` | `""` | no |

## Outputs

Expand All @@ -67,5 +88,4 @@
| codebuild\_role\_id | CodeBuild IAM Role ID |
| codepipeline\_arn | CodePipeline ARN |
| codepipeline\_id | CodePipeline ID |

<!-- markdownlint-restore -->
22 changes: 22 additions & 0 deletions main.tf
Expand Up @@ -285,4 +285,26 @@ resource "aws_codepipeline" "default" {
}
}
}

dynamic "stage" {
for_each = var.website_bucket_name != "" ? ["true"] : []
content {
name = "Deploy"

action {
name = "Deploy"
category = "Deploy"
owner = "AWS"
provider = "S3"
input_artifacts = ["package"]
version = "1"

configuration = {
BucketName = var.website_bucket_name
Extract = "true"
CannedACL = "public-read"
}
}
}
}
}
6 changes: 6 additions & 0 deletions variables.tf
Expand Up @@ -135,3 +135,9 @@ variable "versioning_enabled" {
default = true
description = "A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket"
}

variable "website_bucket_name" {
type = string
default = ""
description = "Name of the S3 bucket where the website will be deployed"
}