์ฌ๋ณด์ธ์. ๋๋ ๋ช ๊ฐ์ง ๋ฌธ์ ์์ ์ด ์ค๋ฅ๋ฅผ ๋ณด์๊ณ ํผ๊ณคํ ๊ฒ์ ๋๋ค. ํด๊ฒฐ์ฑ ์ด ๋ฌด์์ธ์ง๋ ๋ถ๋ช ํ์ง ์์ต๋๋ค. ๋ฒํท ์ ์ฑ ์ ์ ๋ก๋ํ๋ ค๊ณ ํ๋๋ฐ JSON ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ค์ด๋ก๋(์ ๋ ฅํ๊ธฐ ์ํด UI๋ฅผ ์ฌ์ฉํ๊ณ ์ ์๋ํจ)/์ ๋ก๋ํ๊ณ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ด ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ ๋ก๋ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์ ์ ์ฌํญ์ด ์์ต๋๊น? ์ข์ ์ผ์ ๊ณ์ํ์ญ์์ค!
$ aws s3api get-bucket-policy --bucket cloud-1-$NAME > student-1-bucket.manual.json
$ aws s3api put-bucket-policy --bucket cloud-1-$NAME --policy student-1-bucket.manual.json
An error occurred (MalformedPolicy) when calling the PutBucketPolicy operation: Policies must be valid JSON and the first byte must be '{'
$ cat student-1-bucket.manual.json
{
"Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"ExampleStatement1\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::934017622331:user/student-1-cloud\"},\"Action\":\"*\",\"Resource\":\"arn:aws:s3:::cloud-1-14604\"}]}"
}
$
--policy
์ผ๋ฐ์ ์ผ๋ก ํ์ผ ์ด๋ฆ์ด ์ค์ ๋ก ์ฌ์ฉํ๋ ค๋ JSON ๋ฌธ์๋ผ๊ณ ์๊ฐํ๋ JSON ๋ฌธ์์ด์ ํ์ฉํฉ๋๋ค. ํ์ผ์ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด file://
ํ๋กํ ์ฝ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
aws s3api put-bucket-policy --bucket cloud-1-$NAME --policy file://student-1-bucket.manual.json
์ฐธ๊ณ ์ฌ์ฉ์ ํ๊ฒฝ์ ๋ํ ์ก์ธ์ค ๊ถํ์ด ์์ผ๋ฏ๋ก file://
๋นํธ๊ฐ ์คํจํ๋ฉด ๋์ student-1-bucket.manual.json
๋ํ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค.
@cwgem ๋น์ ์ด ์์ ํ ๋ง์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค.
์ฌ์:
aws s3api put-bucket-policy \
--bucket $BucketName \
--policy file://$PathToPolicy/bucketpolicy.json
์๋ฅผ ๋ค์ด:
aws s3api put-bucket-policy \
--bucket firstbucket.mydomain.com \
--policy file:///Users/Andy/Desktop/bucketpolicy.json
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
--policy
์ผ๋ฐ์ ์ผ๋ก ํ์ผ ์ด๋ฆ์ด ์ค์ ๋ก ์ฌ์ฉํ๋ ค๋ JSON ๋ฌธ์๋ผ๊ณ ์๊ฐํ๋ JSON ๋ฌธ์์ด์ ํ์ฉํฉ๋๋ค. ํ์ผ์ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ดfile://
ํ๋กํ ์ฝ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.์ฐธ๊ณ ์ฌ์ฉ์ ํ๊ฒฝ์ ๋ํ ์ก์ธ์ค ๊ถํ์ด ์์ผ๋ฏ๋ก
file://
๋นํธ๊ฐ ์คํจํ๋ฉด ๋์student-1-bucket.manual.json
๋ํ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค.