Skip to content

Commit

Permalink
Log stackname for subscriptions install (#298)
Browse files Browse the repository at this point in the history
* add stackname in logs
  • Loading branch information
chaudharysaket authored Sep 12, 2024
1 parent 83fbaaa commit f925d5a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions newrelic_lambda_cli/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def create_log_subscription(input, function_name):
destination = get_newrelic_log_ingestion_function(input.session, input.stackname)
if destination is None:
failure(
"Could not find newrelic-log-ingestion function. Is the New Relic AWS "
"integration installed?"
"Could not find newrelic-log-ingestion function in stack: %s. Is the New Relic AWS "
"integration installed?" % input.stackname
)
return False
destination_arn = destination["Configuration"]["FunctionArn"]
Expand Down
34 changes: 32 additions & 2 deletions tests/cli/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_subscriptions_install(aws_credentials, cli_runner):
assert result.exit_code == 1
assert result.stdout == ""
assert (
"Could not find newrelic-log-ingestion function. "
"Could not find newrelic-log-ingestion function in stack: NewRelicLogIngestion. "
"Is the New Relic AWS integration installed?"
) in result.stderr

Expand Down Expand Up @@ -60,10 +60,40 @@ def test_subscriptions_install(aws_credentials, cli_runner):
assert result2.exit_code == 1
assert result2.stdout == ""
assert (
"Could not find newrelic-log-ingestion function. "
"Could not find newrelic-log-ingestion function in stack: NewRelicLogIngestion. "
"Is the New Relic AWS integration installed?"
) in result2.stderr

result3 = cli_runner.invoke(
cli,
[
"subscriptions",
"install",
"--no-aws-permissions-check",
"--function",
"foobar",
"--function",
"barbaz",
"--aws-region",
"us-east-1",
"--stackname",
"MyCustomStackName",
],
env={
"AWS_ACCESS_KEY_ID": "testing",
"AWS_SECRET_ACCESS_KEY": "testing",
"AWS_SECURITY_TOKEN": "testing",
"AWS_SESSION_TOKEN": "testing",
},
)

assert result3.exit_code == 1
assert result3.stdout == ""
assert (
"Could not find newrelic-log-ingestion function in stack: MyCustomStackName. "
"Is the New Relic AWS integration installed?"
) in result3.stderr


@mock_aws
def test_subscriptions_uninstall(aws_credentials, cli_runner):
Expand Down

0 comments on commit f925d5a

Please sign in to comment.