This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added updated iam policy and role validations
- Loading branch information
1 parent
080aaf7
commit 1b2d51b
Showing
9 changed files
with
124 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./security-group"; | ||
export * from "./role"; | ||
export * from "./iam-role"; | ||
export * from "./iam-policy"; | ||
export * from "./s3-bucket"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { AwsProvider } from "@cdktf/provider-aws"; | ||
import { TerraformStack, Testing } from "cdktf"; | ||
import "cdktf/lib/testing/adapters/jest"; | ||
import { fusionaws } from "../src"; | ||
import { NOT_SECURE } from "../src/@types/security"; | ||
|
||
Testing.setupJest(); | ||
|
||
describe("AWS", () => { | ||
describe("Security group", () => { | ||
const app = Testing.app(); | ||
const stack = new TerraformStack(app, "test"); | ||
new AwsProvider(stack, "provider"); | ||
|
||
it("should produce valid terraform", () => { | ||
const properties: fusionaws.SecurityGroupProps = { | ||
name: "my-security-group", | ||
}; | ||
|
||
new fusionaws.SecurityGroup(stack, "test-security-group", properties); | ||
expect(Testing.fullSynth(stack)).toBeValidTerraform(); | ||
}); | ||
}); | ||
|
||
describe("s3 bucket", () => { | ||
const app = Testing.app(); | ||
const stack = new TerraformStack(app, "test"); | ||
|
||
new AwsProvider(stack, "provider"); | ||
|
||
it("should produce valid terraform", () => { | ||
const properties: fusionaws.S3BucketProps = { | ||
bucket: "my-bucket", | ||
encryptionKey: NOT_SECURE, | ||
}; | ||
|
||
new fusionaws.S3Bucket(stack, "test-s3-bucket", properties); | ||
expect(Testing.fullSynth(stack)).toBeValidTerraform(); | ||
}); | ||
}); | ||
|
||
describe("IAM role", () => { | ||
const app = Testing.app(); | ||
const stack = new TerraformStack(app, "test"); | ||
new AwsProvider(stack, "provider"); | ||
|
||
it("should produce valid terraform", () => { | ||
const properties: fusionaws.IamRoleProps = { | ||
name: "my-iam-role", | ||
assumeRolePolicy: JSON.stringify({ | ||
Version: "2012-10-17", | ||
Statement: [ | ||
{ | ||
Action: "sts:AssumeRole", | ||
Principal: { | ||
Service: "ec2.amazonaws.com", | ||
}, | ||
Effect: "Allow", | ||
}, | ||
], | ||
}), | ||
}; | ||
|
||
new fusionaws.IamRole(stack, "test-iam-role", properties); | ||
expect(Testing.fullSynth(stack)).toBeValidTerraform(); | ||
}); | ||
}); | ||
|
||
describe("IAM policy", () => { | ||
const app = Testing.app(); | ||
const stack = new TerraformStack(app, "test"); | ||
new AwsProvider(stack, "provider"); | ||
|
||
it("should produce valid terraform", () => { | ||
const properties: fusionaws.IamPolicyProps = { | ||
name: "my-iam-policy", | ||
path: "*", | ||
policy: JSON.stringify({ | ||
Version: "2012-10-17", | ||
Statement: [ | ||
{ | ||
Action: "sts:AssumeRole", | ||
Principal: { | ||
Service: "ec2.amazonaws.com", | ||
}, | ||
Effect: "Allow", | ||
}, | ||
], | ||
}), | ||
}; | ||
|
||
new fusionaws.IamPolicy(stack, "test-iam-policy", properties); | ||
expect(Testing.fullSynth(stack)).toBeValidTerraform(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.