-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to cache resolved output values
- Loading branch information
Showing
21 changed files
with
311 additions
and
36 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-a/config.yml
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 @@ | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_1_ID }}:role/OrganizationAccountAccessRole |
2 changes: 2 additions & 0 deletions
2
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-a/stack1.yml
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,2 @@ | ||
regions: us-east-1 | ||
template: stack1.yml |
11 changes: 11 additions & 0 deletions
11
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-a/stack2.yml
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,11 @@ | ||
regions: eu-west-1 | ||
template: stack2.yml | ||
parameters: | ||
Code: | ||
resolver: external-stack-output | ||
stack: account-a-stack1 | ||
region: us-east-1 | ||
output: MyCode | ||
confidential: true | ||
cache: true | ||
depends: /account-a/stack1.yml |
1 change: 1 addition & 0 deletions
1
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-b/config.yml
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 @@ | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_2_ID }}:role/OrganizationAccountAccessRole |
19 changes: 19 additions & 0 deletions
19
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-b/stack3.yml
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,19 @@ | ||
regions: us-east-1 | ||
template: stack3.yml | ||
parameters: | ||
Code: | ||
resolver: external-stack-output | ||
stack: account-a-stack1 | ||
output: MyCode | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_1_ID }}:role/OrganizationAccountAccessRole | ||
cache: true | ||
Code2: | ||
resolver: external-stack-output | ||
stack: account-c-stack4 | ||
output: MyCode | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_3_ID }}:role/OrganizationAccountAccessRole | ||
region: eu-north-1 | ||
cache: true | ||
depends: | ||
- /account-a/stack1.yml | ||
- /account-c/stack4.yml |
19 changes: 19 additions & 0 deletions
19
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-b/stack5.yml
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,19 @@ | ||
regions: us-east-1 | ||
template: stack5.yml | ||
parameters: | ||
Code3: | ||
resolver: external-stack-output | ||
stack: account-c-stack4 | ||
output: MyCode | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_3_ID }}:role/OrganizationAccountAccessRole | ||
region: eu-north-1 | ||
cache: true | ||
Code4: | ||
resolver: external-stack-output | ||
stack: account-a-stack1 | ||
output: MyCode | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_1_ID }}:role/OrganizationAccountAccessRole | ||
cache: true | ||
depends: | ||
- /account-a/stack1.yml | ||
- /account-c/stack4.yml |
1 change: 1 addition & 0 deletions
1
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-c/config.yml
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 @@ | ||
commandRole: arn:aws:iam::{{ var.ACCOUNT_3_ID }}:role/OrganizationAccountAccessRole |
2 changes: 2 additions & 0 deletions
2
...ation-test/configs/resolvers/external-stack-output-with-cache/stacks/account-c/stack4.yml
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,2 @@ | ||
regions: eu-north-1 | ||
template: stack4.yml |
8 changes: 8 additions & 0 deletions
8
integration-test/configs/resolvers/external-stack-output-with-cache/templates/stack1.yml
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,8 @@ | ||
Resources: | ||
LogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: {} | ||
Outputs: | ||
MyCode: | ||
Description: Code | ||
Value: 123456789 |
9 changes: 9 additions & 0 deletions
9
integration-test/configs/resolvers/external-stack-output-with-cache/templates/stack2.yml
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,9 @@ | ||
Parameters: | ||
Code: | ||
Type: String | ||
Description: Code | ||
Resources: | ||
LogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: | ||
LogGroupName: !Sub log-group-${Code} |
16 changes: 16 additions & 0 deletions
16
integration-test/configs/resolvers/external-stack-output-with-cache/templates/stack3.yml
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,16 @@ | ||
Parameters: | ||
Code: | ||
Type: String | ||
Description: Code | ||
AllowedValues: | ||
- "123456789" | ||
Code2: | ||
Type: String | ||
Description: Code | ||
AllowedValues: | ||
- Reggae | ||
Resources: | ||
LogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: | ||
LogGroupName: !Sub log-group-${Code}-${Code2} |
8 changes: 8 additions & 0 deletions
8
integration-test/configs/resolvers/external-stack-output-with-cache/templates/stack4.yml
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,8 @@ | ||
Resources: | ||
LogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: {} | ||
Outputs: | ||
MyCode: | ||
Description: Code | ||
Value: Reggae |
16 changes: 16 additions & 0 deletions
16
integration-test/configs/resolvers/external-stack-output-with-cache/templates/stack5.yml
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,16 @@ | ||
Parameters: | ||
Code3: | ||
Type: String | ||
Description: Code | ||
AllowedValues: | ||
- Reggae | ||
Code4: | ||
Type: String | ||
Description: Code | ||
AllowedValues: | ||
- "123456789" | ||
Resources: | ||
LogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: | ||
LogGroupName: !Sub log-group-${Code3}-${Code4}-3 |
46 changes: 46 additions & 0 deletions
46
integration-test/test/resolvers/external-stack-output-with-cache.test.ts
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,46 @@ | ||
/** | ||
* @testenv-recycler-count 3 | ||
*/ | ||
|
||
import { | ||
executeDeployStacksCommand, | ||
executeUndeployStacksCommand, | ||
} from "../../src/commands/stacks.js" | ||
|
||
const projectDir = `${process.cwd()}/integration-test/configs/resolvers/external-stack-output-with-cache` | ||
const stacks = [ | ||
{ | ||
stackName: "account-a-stack1", | ||
stackPath: "/account-a/stack1.yml/us-east-1", | ||
}, | ||
{ | ||
stackName: "account-a-stack2", | ||
stackPath: "/account-a/stack2.yml/eu-west-1", | ||
}, | ||
{ | ||
stackName: "account-b-stack3", | ||
stackPath: "/account-b/stack3.yml/us-east-1", | ||
}, | ||
{ | ||
stackName: "account-b-stack5", | ||
stackPath: "/account-b/stack5.yml/us-east-1", | ||
}, | ||
{ | ||
stackName: "account-c-stack4", | ||
stackPath: "/account-c/stack4.yml/eu-north-1", | ||
}, | ||
] | ||
|
||
describe("External stack output resolver with cache", () => { | ||
test("Deploy", () => | ||
executeDeployStacksCommand({ projectDir, logLevel: "debug" }) | ||
.expectCommandToSucceed() | ||
.expectStackCreateSuccess(...stacks) | ||
.assert()) | ||
|
||
test("Undeploy", () => | ||
executeUndeployStacksCommand({ projectDir }) | ||
.expectCommandToSucceed() | ||
.expectStackDeleteSuccess(...stacks) | ||
.assert()) | ||
}) |
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,5 +1,17 @@ | ||
export interface Cache { | ||
readonly get: (key: string) => Promise<string | undefined> | ||
readonly put: (key: string, value: string) => Promise<void> | ||
readonly get: (key: string) => Promise<unknown> | ||
readonly put: (key: string, value: unknown) => Promise<void> | ||
readonly reset: () => Promise<void> | ||
} | ||
|
||
export const inMemoryCache = () => { | ||
const cache = new Map<string, unknown>() | ||
|
||
return { | ||
get: async (key: string) => cache.get(key), | ||
put: async (key: string, value: unknown) => { | ||
cache.set(key, value) | ||
}, | ||
reset: async () => cache.clear(), | ||
} | ||
} |
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.