Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/core/resources/ec2_connect
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Usage:
# When connecting to a dev environment
# AWS_REGION=… AWS_SSM_CLI=… STREAM_URL=… TOKEN=… LOG_FILE_LOCATION==… ./ec2_connect
# AWS_REGION=… AWS_SSM_CLI=… STREAM_URL=… TOKEN=… LOG_FILE_LOCATION==… DEBUG_LOG=… ./ec2_connect

set -e
set -u
Expand Down Expand Up @@ -44,13 +44,21 @@ _ec2() {

_main() {
_log "=============================================================================="

_require AWS_SSM_CLI "${AWS_SSM_CLI:-}"
_require DEBUG_LOG "${DEBUG_LOG:-}"
_require AWS_REGION "${AWS_REGION:-}"

_require SESSION_ID "${SESSION_ID:-}"
_require_nolog STREAM_URL "${STREAM_URL:-}"
_require_nolog TOKEN "${TOKEN:-}"
_require SESSION_ID "${SESSION_ID:-}"
_require LOG_FILE_LOCATION "${LOG_FILE_LOCATION:-}"

# Only log file paths when debug level is enabled.
if [ "${DEBUG_LOG:-}" -eq 1 ]; then
_require AWS_SSM_CLI "${AWS_SSM_CLI:-}"
_require LOG_FILE_LOCATION "${LOG_FILE_LOCATION:-}"
else
_require_nolog AWS_SSM_CLI "${AWS_SSM_CLI:-}"
_require_nolog LOG_FILE_LOCATION "${LOG_FILE_LOCATION:-}"
fi

_ec2 "$AWS_SSM_CLI" "$AWS_REGION" "$STREAM_URL" "$TOKEN" "$SESSION_ID"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/awsService/ec2/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ export class Ec2Connecter implements vscode.Disposable {
const ssmSession = await this.startSSMSession(selection.instanceId)

const vars = getEc2SsmEnv(selection, ssm, ssmSession)
getLogger().info(`ec2: connect script logs at ${vars.LOG_FILE_LOCATION}`)
getLogger().debug(`ec2: connect script logs at ${vars.LOG_FILE_LOCATION}`)

const envProvider = async () => {
return { [sshAgentSocketVariable]: await startSshAgent(), ...vars }
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/awsService/ec2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { copyToClipboard } from '../../shared/utilities/messages'
import { Ec2Selection } from './prompter'
import { sshLogFileLocation } from '../../shared/sshConfig'
import { SSM } from 'aws-sdk'
import { getLogger } from '../../shared/logger'

export function getIconCode(instance: SafeEc2Instance) {
if (instance.LastSeenStatus === 'running') {
Expand Down Expand Up @@ -42,6 +43,7 @@ export function getEc2SsmEnv(
STREAM_URL: session.StreamUrl,
SESSION_ID: session.SessionId,
TOKEN: session.TokenValue,
DEBUG_LOG: getLogger().logLevelEnabled('debug') ? 1 : 0,
},
process.env
)
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/shared/logger/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { resolvePath } from '../utilities/pathUtils'
import fs from '../../shared/fs/fs'
import { isWeb } from '../extensionGlobals'
import { getUserAgent } from '../telemetry/util'
import { isBeta } from '../vscode/env'
import { isBeta, isDebugInstance } from '../vscode/env'

/**
* Activate Logger functionality for the extension.
Expand Down Expand Up @@ -46,7 +46,10 @@ export async function activate(
const newLogLevel = fromVscodeLogLevel(logLevel)
mainLogger.setLogLevel(newLogLevel) // Also logs a message.
})
mainLogger.setLogLevel('debug') // HACK: set to "debug" when debugging the extension.

if (isDebugInstance()) {
mainLogger.setLogLevel('debug') // HACK: set to "debug" when debugging the extension.
}

setLogger(mainLogger)

Expand Down
Loading