Skip to content

Commit

Permalink
Bucket access check script change (#6)
Browse files Browse the repository at this point in the history
* Testing script change

* Adjust README
  • Loading branch information
LeoDiazL authored Jan 15, 2024
1 parent 5793266 commit 02f9079
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

steps:
- name: Create deploy-bucket
uses: bitovi/[email protected].3
uses: bitovi/[email protected].4
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_SANDBOX}}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SANDBOX}}
Expand Down
11 changes: 8 additions & 3 deletions scripts/create_tf_state_bucket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ else
else
aws s3api create-bucket --bucket $TF_STATE_BUCKET --region $AWS_DEFAULT_REGION --create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION || true
fi

if ! [[ -z $(aws s3api head-bucket --bucket $TF_STATE_BUCKET 2>&1) ]]; then
echo "Bucket does not exist or permission is not there to use it."
touch bitovi-test-file.txt
if ! [[ -z $(aws s3api put-object --bucket $TF_STATE_BUCKET --key bitovi-test-file.txt --body ./bitovi-test-file.txt 2>&1 >/dev/null ) ]]; then
echo "Permission issue: Unable to write to the bucket."
exit 63
else
if ! [[ $(aws s3 rm "s3://$TF_STATE_BUCKET/bitovi-test-file.txt" 2>&1 >/dev/null ) ]]; then
echo "Access to bucket confirmed. Can create and delete a tf-state file"
fi
fi
rm bitovi-test-file.txt
fi
2 changes: 1 addition & 1 deletion terraform_code/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ locals {
GitHubOrgName = "${var.app_org_name}"
GitHubRepoName = "${var.app_repo_name}"
GitHubBranchName = "${var.app_branch_name}"
GitHubAction = "bitovi/github-actions-deploy-serverless-website"
GitHubAction = "bitovi/github-actions-deploy-static-site-to-aws"
created_with = "terraform"
}
}

0 comments on commit 02f9079

Please sign in to comment.