Skip to content

Commit 4a68fa4

Browse files
committed
[Add] - add function to get credentials on ec2 via metadata and add function to know how to copy folder in s3
1 parent d1807eb commit 4a68fa4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

services/ec2.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,13 @@ aws_ec2_other_commandlines() {
205205
fi
206206

207207
}
208+
209+
aws_ec2_get_credential_from_metadata_instruction() {
210+
local aws_meta_data_address="http://169.254.169.254"
211+
cat <<-__EOF__
212+
# Run on ec2
213+
iam_role_name=\$(curl -s '${aws_meta_data_address}/latest/meta-data/iam/security-credentials/')
214+
curl -s ${aws_meta_data_address}/latest/meta-data/iam/security-credentials/\${iam_role_name}
215+
__EOF__
216+
217+
}

services/s3.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,11 @@ aws_s3_get_presigned_url() {
139139
"
140140

141141
}
142+
143+
aws_s3_cp_folder_instruction() {
144+
echo "\
145+
aws s3 cp s3://BUCKET_NAME/cf/cf-domain.com/cf-domain.com-2022-12 \
146+
s3://NEW_BUCKET_NAME/cf-domain.com-2022-12/00-10 --recursive --exclude \"*\" --include \"CF_ID.2022-12-0*\"
147+
"
148+
149+
}

0 commit comments

Comments
 (0)