Skip to content

Commit

Permalink
Removing last-used checks on credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
tstibbs committed Nov 18, 2024
1 parent 434a536 commit 2bd20b8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
9 changes: 1 addition & 8 deletions aws/environment-setup/lib/deploy-parent-tooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import events from 'aws-cdk-lib/aws-events'
import eventsTargets from 'aws-cdk-lib/aws-events-targets'
import dynamodb from 'aws-cdk-lib/aws-dynamodb'

import {
CHILD_ACCOUNTS,
RAW_CHILD_ACCOUNTS,
MAX_CREDENTIAL_AGE,
MAX_UNUSED_CREDENTIAL_DAYS,
DEV_SUFFIX
} from './deploy-envs.js'
import {CHILD_ACCOUNTS, RAW_CHILD_ACCOUNTS, MAX_CREDENTIAL_AGE, DEV_SUFFIX} from './deploy-envs.js'
import {PARENT_ACCNT_CLI_ROLE_NAME} from './deploy-utils.js'
import {MONITOR_STORE_SCHEMA} from '../src/constants.js'
import {createParentUsageMonitorResources} from './deploy-shared-usage.js'
Expand Down Expand Up @@ -72,7 +66,6 @@ function createLambda(stack, notificationTopic) {
ALERTS_TOPIC: notificationTopic.topicArn,
CHILD_ACCOUNTS: RAW_CHILD_ACCOUNTS,
MAX_CREDENTIAL_AGE,
MAX_UNUSED_CREDENTIAL_DAYS,
MONITOR_TABLE_NAME: monitorStoreTable.tableName
},
memorySize: 128,
Expand Down
8 changes: 2 additions & 6 deletions aws/environment-setup/src/iam-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {parse as csvParse} from 'csv-parse/sync'
import backOff from 'exponential-backoff'

import {MAX_CREDENTIAL_AGE, MAX_UNUSED_CREDENTIAL_DAYS} from './runtime-envs.js'
import {MAX_CREDENTIAL_AGE} from './runtime-envs.js'
import {buildApiForAccount, buildMultiAccountLambdaHandler} from './utils.js'
import {MonitorStore} from './monitor-store.js'

Expand All @@ -16,7 +16,6 @@ async function checkOneAccount(accountId) {
const issues = []
const now = Date.now()
const maxCredentialAge = MAX_CREDENTIAL_AGE //in days
const maxUnusedCredentialDays = MAX_UNUSED_CREDENTIAL_DAYS //in days
const iam = await buildApiForAccount(accountId, 'ParentAccountCliRole', 'IAM')

async function runChecks() {
Expand All @@ -42,7 +41,7 @@ async function checkOneAccount(accountId) {
rootMfaEnabled(rootUsers)
// check MFA enabled for all users with console access
consoleUsersMfaEnabled(nonRootUsers)
// Check no access keys older than x days and no credentials that have been unused for x days
// Check no access keys older than x days
checkCredentials(nonRootUsers)
}

Expand Down Expand Up @@ -72,15 +71,12 @@ async function checkOneAccount(accountId) {
function checkCredentials(nonRootUsers) {
nonRootUsers.forEach(user => {
if (user.password_enabled === 'true') {
dateMoreRecentThan(user, 'password_last_used', maxUnusedCredentialDays)
dateMoreRecentThan(user, 'password_last_changed', maxCredentialAge)
}
if (user.access_key_1_active === 'true') {
dateMoreRecentThan(user, 'access_key_1_last_used_date', maxUnusedCredentialDays)
dateMoreRecentThan(user, 'access_key_1_last_rotated', maxCredentialAge)
}
if (user.access_key_2_active === 'true') {
dateMoreRecentThan(user, 'access_key_2_last_used_date', maxUnusedCredentialDays)
dateMoreRecentThan(user, 'access_key_2_last_rotated', maxCredentialAge)
}
})
Expand Down
1 change: 0 additions & 1 deletion aws/environment-setup/src/runtime-envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const {
WARNING_BUDGET,
MAX_BUDGET,
MAX_CREDENTIAL_AGE,
MAX_UNUSED_CREDENTIAL_DAYS,
NOTIFICATION_EMAIL,
ORG_ID,
PARENT_ACCOUNT_ID,
Expand Down

0 comments on commit 2bd20b8

Please sign in to comment.