-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mayank0202
committed
Jun 27, 2024
1 parent
80732ee
commit 7960d84
Showing
20 changed files
with
1,433 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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,54 @@ | ||
--- | ||
name: "Run Pre Commit Checks" | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: | ||
- '**' | ||
- '!main' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
## run pre-commit | ||
pre-commit: | ||
name: Run pre-commit checks | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
actions: write | ||
pages: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.ARC_JOB_TOKEN }} | ||
|
||
- uses: actions/setup-python@v3 | ||
|
||
- name: Install terraform-docs | ||
run: | | ||
cd /tmp | ||
curl -sSLo ./terraform-docs.tar.gz \ | ||
https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz | ||
tar -xzf terraform-docs.tar.gz | ||
rm terraform-docs.tar.gz | ||
chmod +x terraform-docs | ||
mv terraform-docs /usr/local/bin/terraform-docs | ||
- name: Install tflint | ||
run: | | ||
cd /tmp | ||
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
continue-on-error: true # we want to push the changes pre-commit makes | ||
|
||
- name: Push pre-commit changes to branch | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: Push pre-commit changes |
This file contains 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,29 @@ | ||
--- | ||
name: Bump version | ||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Bump version and push tag | ||
id: tag | ||
uses: anothrNick/github-tag-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
DEFAULT_BUMP: patch | ||
REPO_OWNER: sourcefuse | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag.outputs.tag }} | ||
release_name: v${{ steps.tag.outputs.tag }} | ||
body: ${{ github.release_notes }} | ||
draft: false | ||
prerelease: false |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains 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,50 @@ | ||
--- | ||
name: Update-docs | ||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
transfer-file: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Pushes Readme file | ||
uses: dmnemec/copy_file_to_another_repo_action@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }} | ||
with: | ||
source_file: 'README.md' | ||
destination_repo: 'sourcefuse/arc-docs' | ||
destination_folder: 'docs/arc-iac-docs/modules/terraform-aws-arc-s3' | ||
user_email: '[email protected]' | ||
user_name: ${{ github.actor }} | ||
commit_message: ${{ github.event.head_commit.message }} | ||
- name: Pushes Module Usage Guide | ||
uses: dmnemec/copy_file_to_another_repo_action@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }} | ||
with: | ||
source_file: 'docs/module-usage-guide/README.md' | ||
destination_repo: 'sourcefuse/arc-docs' | ||
destination_folder: 'docs/arc-iac-docs/modules/terraform-aws-arc-s3/docs/module-usage-guide' | ||
user_email: '[email protected]' | ||
user_name: ${{ github.actor }} | ||
commit_message: ${{ github.event.head_commit.message }} | ||
- name: Pushes to another repository | ||
uses: cpina/github-action-push-to-another-repository@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }} | ||
with: | ||
source-directory: 'static' | ||
destination-github-username: 'sourcefuse' | ||
destination-repository-name: 'arc-docs' | ||
target-directory: 'docs/arc-iac-docs/modules/terraform-aws-arc-s3/static' | ||
user-email: '[email protected]' | ||
user-name: ${{ github.actor }} | ||
target-branch: main | ||
commit-message: ${{ github.event.head_commit.message }} |
This file contains 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 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,150 @@ | ||
data "aws_partition" "current" {} | ||
data "aws_canonical_user_id" "default" {} | ||
data "aws_iam_policy_document" "bucket_policy" { | ||
|
||
dynamic "statement" { | ||
for_each = var.allow_encrypted_uploads_only ? [1] : [] | ||
|
||
content { | ||
sid = "DenyIncorrectEncryptionHeader" | ||
effect = "Deny" | ||
actions = ["s3:PutObject"] | ||
resources = ["${local.bucket_arn}/*"] | ||
|
||
principals { | ||
identifiers = ["*"] | ||
type = "*" | ||
} | ||
|
||
condition { | ||
test = "StringNotEquals" | ||
values = [var.sse_algorithm] | ||
variable = "s3:x-amz-server-side-encryption" | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = var.allow_encrypted_uploads_only ? [1] : [] | ||
|
||
content { | ||
sid = "DenyUnEncryptedObjectUploads" | ||
effect = "Deny" | ||
actions = ["s3:PutObject"] | ||
resources = ["${local.bucket_arn}/*"] | ||
|
||
principals { | ||
identifiers = ["*"] | ||
type = "*" | ||
} | ||
|
||
condition { | ||
test = "Null" | ||
values = ["true"] | ||
variable = "s3:x-amz-server-side-encryption" | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = var.allow_ssl_requests_only ? [1] : [] | ||
|
||
content { | ||
sid = "ForceSSLOnlyAccess" | ||
effect = "Deny" | ||
actions = ["s3:*"] | ||
resources = [local.bucket_arn, "${local.bucket_arn}/*"] | ||
|
||
principals { | ||
identifiers = ["*"] | ||
type = "*" | ||
} | ||
|
||
condition { | ||
test = "Bool" | ||
values = ["false"] | ||
variable = "aws:SecureTransport" | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = length(var.s3_replication_source_roles) > 0 ? [1] : [] | ||
|
||
content { | ||
sid = "CrossAccountReplicationObjects" | ||
actions = [ | ||
"s3:ReplicateObject", | ||
"s3:ReplicateDelete", | ||
"s3:ReplicateTags", | ||
"s3:GetObjectVersionTagging", | ||
"s3:ObjectOwnerOverrideToBucketOwner" | ||
] | ||
resources = ["${local.bucket_arn}/*"] | ||
principals { | ||
type = "AWS" | ||
identifiers = var.s3_replication_source_roles | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = length(var.s3_replication_source_roles) > 0 ? [1] : [] | ||
|
||
content { | ||
sid = "CrossAccountReplicationBucket" | ||
actions = ["s3:List*", "s3:GetBucketVersioning", "s3:PutBucketVersioning"] | ||
resources = [local.bucket_arn] | ||
principals { | ||
type = "AWS" | ||
identifiers = var.s3_replication_source_roles | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = var.privileged_principal_arns | ||
|
||
content { | ||
sid = "AllowPrivilegedPrincipal[${statement.key}]" # add indices to Sid | ||
actions = var.privileged_principal_actions | ||
resources = distinct(flatten([ | ||
"arn:${local.partition}:s3:::${local.bucket_id}", | ||
formatlist("arn:${local.partition}:s3:::${local.bucket_id}/%s*", values(statement.value)[0]), | ||
])) | ||
principals { | ||
type = "AWS" | ||
identifiers = [keys(statement.value)[0]] | ||
} | ||
} | ||
} | ||
|
||
dynamic "statement" { | ||
for_each = length(var.source_ip_allow_list) > 0 ? [1] : [] | ||
|
||
content { | ||
sid = "AllowIPPrincipals" | ||
effect = "Deny" | ||
actions = ["s3:*"] | ||
resources = [local.bucket_arn, "${local.bucket_arn}/*"] | ||
principals { | ||
identifiers = ["*"] | ||
type = "*" | ||
} | ||
condition { | ||
test = "NotIpAddress" | ||
variable = "aws:SourceIp" | ||
values = var.source_ip_allow_list | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
data "aws_iam_policy_document" "aggregated_policy" { | ||
count = var.enabled ? 1 : 0 | ||
|
||
source_policy_documents = [one(data.aws_iam_policy_document.bucket_policy[*].json)] | ||
override_policy_documents = var.source_policy_documents | ||
} |
Oops, something went wrong.