-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,968 additions
and
2,188 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,25 @@ | ||
import {STS} from '@aws-sdk/client-sts' | ||
|
||
const awsDefaults = {region: 'eu-west-2'} | ||
const awsApiVersions = { | ||
Athena: '2017-05-18', | ||
CloudFormation: '2010-05-15', | ||
CloudWatchLogs: '2014-03-28', | ||
DynamoDB: '2012-08-10', | ||
IAM: '2010-05-08', | ||
IoT: '2015-05-28', | ||
S3: '2006-03-01', | ||
SNS: '2010-03-31', | ||
STS: '2011-06-15' | ||
} | ||
import {defaultAwsClientConfig} from '@tstibbs/cloud-core-utils/src/tools/aws-client-config.js' | ||
import {fromTemporaryCredentials, fromNodeProviderChain} from '@aws-sdk/credential-providers' | ||
|
||
export function defaultsForAwsService(serviceName) { | ||
//TODO remove this | ||
return { | ||
...awsDefaults, | ||
apiVersion: awsApiVersions[serviceName] | ||
...defaultAwsClientConfig | ||
} | ||
} | ||
|
||
export async function assumeRole(roleArn) { | ||
let sts = new STS(defaultsForAwsService('STS')) | ||
let sts = new STS(defaultAwsClientConfig) | ||
let currentAuth = await sts.getCallerIdentity({}) | ||
let currentSessionName = currentAuth.Arn.split('/').slice(-1)[0] | ||
let oldCreds = aws.config.credentials | ||
aws.config.credentials = new aws.ChainableTemporaryCredentials({ | ||
params: { | ||
RoleArn: roleArn, | ||
RoleSessionName: currentSessionName | ||
} | ||
}) | ||
return oldCreds | ||
return { | ||
credentials: fromTemporaryCredentials({ | ||
masterCredentials: fromNodeProviderChain(), | ||
params: { | ||
RoleArn: roleArn, | ||
RoleSessionName: currentSessionName | ||
} | ||
}) | ||
} | ||
} |
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
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,12 +1,12 @@ | ||
import {PARENT_ACCOUNT_ID} from '../lib/deploy-envs.js' | ||
import {assumeRole} from '../src/auth-utils.js' | ||
import aws from 'aws-sdk' | ||
import {CloudFormation} from '@aws-sdk/client-cloudformation' | ||
import {defaultAwsClientConfig} from '@tstibbs/cloud-core-utils/src/tools/aws-client-config.js' | ||
|
||
await assumeRole(`arn:aws:iam::${PARENT_ACCOUNT_ID}:role/toolingFunctionsRole`) | ||
// await assumeRole(`arn:aws:iam::${PARENT_ACCOUNT_ID}:role/toolingFunctionsRole`) | ||
let {handler, checkOneStackDriftsAcceptable} = await import('../src/cfnStackDriftChecker.js') | ||
await handler({}, {awsRequestId: 'dummy'}) | ||
// await handler({}, {awsRequestId: 'dummy'}) | ||
|
||
//TODO comment this out by default | ||
let cloudformation = new aws.CloudFormation() | ||
let acceptable = await checkOneStackDriftsAcceptable(cloudformation, stack - name) | ||
let cloudformation = new CloudFormation(defaultAwsClientConfig) | ||
let acceptable = await checkOneStackDriftsAcceptable(cloudformation, 'pdf-viewer-sync') | ||
console.log(acceptable) |