Before setting up the GitHub action, it's important to generate an Access Key for uploading files to the designated bucket. To do so, let’s follow this steps
Create S3 Access Policy
Navigate to the Policies
page and select Create policy
to add a new policy for our bucket.
Next, choose the service as S3.
Now, input the following policy into the text editor:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::my-awesome-project-bucket",
"arn:aws:s3:::my-awesome-project-bucket/*"
]
}
]
}
this is the explaination for the config:
-
Action: Lists the AWS S3 actions allowed by this policy. The allowed actions are:
-
s3:GetObject
: Allowing retrieval of objects from the bucket. -
s3:PutObject
: Allowing the addition of objects to the bucket. -
s3:ListBucket
: Allowing the listing of objects within the bucket. -
s3:DeleteObject
: Allowing the deletion of objects within the bucket.
-
-
Resource: Specifies the AWS resources to which the actions apply. In this case, the resources are:
-
"arn:aws:s3:::my-awesome-project-bucket"
: Refers to the bucket. -
"arn:aws:s3:::my-awesome-project-bucket/*"
: Refers to all objects within the bucket.
-
To get the arn
you can copy it from the properties
section in the bucket page.
Once the configuration is complete, click the Next
button, enter a policy name, and click Create policy
at the bottom of the page.
Create New User Credential
Navigate to the Users
page in the IAM
dashboard and click the Create user
button.
Enter the User name
, then click the Next
button.
Select Attach policies directly
in Permissions options
and choose the policy created earlier. Click the Next
button to proceed to the last step.
Review the configuration in the last step and click Create user
to finish.
Create Access Keys
Navigate to the Users
page, open Security credentials
, and click Create access key
under the Access keys
section.
For the first step, choose the other
option.
In the second step, enter a description for the access key and click the Create access key
button.
Finally, click Download .csv file
and then Done
.
With this setup completed, we are ready to create an automated update to the S3 bucket using GitHub CI.
Top comments (0)