-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tilfin/feature/policy-v2
Policy definition V2
- Loading branch information
Showing
31 changed files
with
421 additions
and
162 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
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
{ | ||
"Policy": { | ||
"PolicyName": "bar-logs-lambda-ENV", | ||
"Path": "/" | ||
}, | ||
"Document": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "arn:aws:logs:*:*:*" | ||
} | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
{ | ||
"Policy": { | ||
"PolicyName": "baz-dynamodb-items-ENV", | ||
"Path": "/" | ||
}, | ||
"Document": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"dynamodb:BatchGetItem", | ||
"dynamodb:BatchWriteItem", | ||
"dynamodb:DescribeStream", | ||
"dynamodb:ListStreams", | ||
"dynamodb:PutItem", | ||
"dynamodb:Query", | ||
"dynamodb:UpdateItem" | ||
], | ||
"Resource": "arn:aws:dynamodb:ap-northeast-1:ACCOUNT_ID:table/baz-items-ENV" | ||
} | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
{ | ||
"Policy": { | ||
"PolicyName": "foo-s3-logs-ENV", | ||
"Path": "/" | ||
}, | ||
"Document": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"s3:PutObject", | ||
"s3:GetObject", | ||
"s3:DeleteObject" | ||
], | ||
"Resource": "arn:aws:s3:::foo-s3-logs-ENV-ACCOUNT_ID/*" | ||
} | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
{ | ||
"Policy": { | ||
"PolicyName": "foo-s3-storage-ENV", | ||
"Path": "/" | ||
}, | ||
"Document": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"s3:PutObject", | ||
"s3:GetObject", | ||
"s3:DeleteObject" | ||
], | ||
"Resource": "arn:aws:s3:::foo-s3-storage-ENV-ACCOUNT_ID/*" | ||
} | ||
] | ||
} | ||
} |
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,52 @@ | ||
#!/usr/bin/env | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
async function readJSONFile(filePath) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(filePath, 'utf8', (err, text) => { | ||
if (err) reject(err) | ||
else resolve(JSON.parse(text)) | ||
}) | ||
}) | ||
} | ||
|
||
async function writeJSONFile(filePath, content) { | ||
const json = JSON.stringify(content, null, 4) | ||
return new Promise((resolve, reject) => { | ||
fs.writeFile(filePath, json, function(err) { | ||
if (err) reject(err) | ||
else resolve() | ||
}) | ||
}) | ||
} | ||
|
||
;(async () => { | ||
const filePath = process.argv[2] | ||
if (!filePath) { | ||
console.log('Usage) node upgrade_policy.js <policy JSON file>') | ||
process.exit(2) | ||
return | ||
} | ||
|
||
const document = await readJSONFile(filePath) | ||
if (document.Document) { | ||
console.warn('[WARN] %s : This policy definition is already new version.', filePath) | ||
process.exit(3) | ||
return | ||
} | ||
|
||
const newDoc = { | ||
Policy: { | ||
PolicyName: path.basename(filePath, '.json'), | ||
Path: '/' | ||
}, | ||
Document: document | ||
} | ||
await writeJSONFile(filePath, newDoc) | ||
})() | ||
.catch(err => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
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
Oops, something went wrong.