Skip to Content
IntegrationsCloudAWSServerless

AWS Serverless Integration Troubleshooting

Debug deployment, scanning, and update issues for the Mondoo serverless AWS integration.

Troubleshoot the Mondoo serverless AWS integration: CloudFormation, Lambda updates, VPC access, logging, and Terraform interactions.

To stop scheduled scans at any time, open the ... menu on the integration page and select Pause. Select Resume from the same menu to start scanning again.

CloudFormation

Single-account stack failed to create

If CloudFormation can't complete a single stack, Mondoo reports the failure.

  1. Check the AWS CloudFormation console for the error details.
  2. Resolve the error.
  3. Open the integration page in Mondoo. While the integration waits for the stack, it shows a Waiting for CloudFormation banner. Select LAUNCH AWS CLOUDFORMATION in the banner to launch the stack again. If Mondoo reports that the stack was deleted, select recreate the stack in the CloudFormation Stack Deleted banner instead.

Organization StackSet failed to create

If the StackSet doesn't complete, you see an incomplete list of AWS accounts in Mondoo.

  1. Check the AWS CloudFormation console for the error details and resolve it.
  2. Open the StackSet in the AWS CloudFormation console.
  3. From the Actions menu in the top-right corner, select Edit StackSet details.
  4. Step through the wizard without changing values. Some fields require you to re-enter them.
  5. Submit to update the StackSet.
  6. On the Operations tab, refresh to see the update progress.

Requirements for deploying the Mondoo StackSet at the organization level

Your AWS Organization must follow AWS core principles. The most common blocker is missing organizational units (OUs).

In the AWS Organizations console, confirm:

  • The top-level entity is root, with an ID like r-ab12.
  • root contains one or more OUs with IDs like ou-ab12-1234abcd.

If the entities below root have IDs like o-abcd5678, an organization-level integration won't deploy. Use a single-account install for each account instead.

A failed org-level attempt leaves StackSets and roles in the target accounts. AWS often blocks deleting them from the console with this error:

An error occurred (ValidationError) when calling the DeleteStackInstances operation:
StackSets with SERVICE_MANAGED permission model can only have OrganizationalUnit as target

You must remove these StackSet instances with the AWS CLI.

Remove a faulty StackSet from the organization root

Use aws cloudformation delete-stack-instances:

Read the AWS CLI reference before running this in your infrastructure.

  • STACK-SET-NAME-USUALLY-MONDOO: the StackSet name (default Mondoo).
  • ROOT-OU-ID: your Organization root ID, such as r-85mw.
  • REGION: the Organization's region, such as us-east-1.
aws cloudformation delete-stack-instances \
--stack-set-name STACK-SET-NAME-USUALLY-MONDOO \
--deployment-targets OrganizationUnitIds=ROOT-OU-ID \
--regions REGION \
--no-retain-stacks

Manually remove Mondoo roles from an AWS account

If you remove a Mondoo integration by hand, also delete every Mondoo IAM role in the account:

  • mondoo-lambda-role
  • mondoo-event-bus-role
  • mondoo-ebs-scanner-role
  • mondoo-ecr-scanner-role
  • mondoo-scheduler-role
  • mondoo-updater-role
  • mondoo-account-scanner-role

mondoo-account-scanner-role is the default name. If you changed the stack's AccountScannerRoleName parameter, delete the role with the name you chose.

Updates

Every 3 hours, an EventBridge rule triggers the Mondoo Updater Lambda, which checks Mondoo's S3 bucket for a new build and updates the Mondoo Lambda's function code directly, without a CloudFormation stack update. When Mondoo publishes a new version of the CloudFormation template itself, updating the stack can land in Update Failed: sometimes it's a chicken-and-egg issue that resolves on the next pass, sometimes it needs a manual stack update to grant extra permissions.

Update the stack to the current template

The Updater Lambda replaces only the Lambda's code. Changes to the CloudFormation template, such as new permissions or new instance types the scanner may launch, reach your account only when you update the stack (or, for an organization install, the StackSet) to the current template. The release notes list the template changes in each release.

To see which template your stack runs, open the integration page and find the CloudFormation template version row in the INTEGRATION CONFIGURATION section. The row shows the release whose template the stack was deployed or last updated with. If it shows an earlier release than the Scanner version row, or only the Scanner version row appears, the stack runs the template of an earlier release.

To get the template URL, copy the View CloudFormation Configuration link in the AWS CloudFormation row of the same section. It points to the current template in your install region. For us-east-1, the URL is https://s3.amazonaws.com/mondoo.us-east-1/mondoo-serverless-v2.json.

Single-account stack:

  1. Sign in to the AWS account where the Mondoo stack runs, open the AWS CloudFormation console, and switch to the install region.
  2. Select the Mondoo stack, then select Update.
  3. Select Replace existing template, choose Amazon S3 URL, and paste the template URL.
  4. Keep the existing parameter values. For a parameter that CloudFormation doesn't fill in, select Use existing value.
  5. Acknowledge that the template may create IAM resources, then update the stack. Wait for the status to reach UPDATE_COMPLETE.

Organization StackSet:

  1. Sign in to the management account (or the delegated StackSets administrator account), open the AWS CloudFormation console, and switch to the region where you created the StackSet.
  2. Select StackSets, then select the Mondoo StackSet.
  3. From the Actions menu, select Edit StackSet details.
  4. Select Replace current template, choose Amazon S3 URL, and paste the template URL.
  5. Keep the existing parameter values. Some fields require you to re-enter them.
  6. Acknowledge that the template may create IAM resources, deploy to the same organizational units and region as before, and submit.
  7. On the Operations tab, refresh to see the update progress.

If you use cross-account scanning, the cross-account role in your target accounts comes from a separate template. When a release changes that template, update its StackSet the same way, with the cross-account role template URL.

Pinned scanner versions

If you pinned the scanner to a specific release when you created the integration (the Scanner version option), the Updater Lambda doesn't update it. The integration page shows the deployed version beside the integration name. When a newer release is available, select the version to see how to update the stack: in the AWS CloudFormation console, update the stack with the existing template and set the FixedVersion parameter to the new release.

Lambda VPC access

The Mondoo Lambda role has the AWSLambdaVPCAccessExecutionRole policy attached so it can discover and scan assets.

If the Lambda needs VPC access to reach private instances, follow Configuring a Lambda function to access resources in a VPC.

SSM-managed instance security groups must allow outbound traffic on port 443 (HTTPS) to Mondoo Platform so scan results can be sent back. That includes both the API endpoint (us.api.mondoo.com) and the ingest endpoint (ingest.us.mondoo.com). For the full list of hosts and IP addresses, read Communication matrix, IPs, and DNS names.

Test SSM access in a custom VPC

With the Custom VPC option, scans fail when the scanner instances in the tagged subnets can't register with AWS Systems Manager (SSM). To test a tagged subnet, launch your own instance in it and check that the instance registers. You can do this before you install the integration or when its scans fail.

  1. Launch an EC2 instance in a tagged subnet, in a region that the integration scans:

    • Use an Amazon Linux 2023 AMI. Like the scanner, it has the SSM agent installed.
    • Use the security group that carries the VPC's tag or, if none does, the VPC's default security group.
    • Leave the public IP setting at the subnet's default. The scanner doesn't request a public address either.
    • Attach an instance profile whose role has the AWS managed policy AmazonSSMManagedInstanceCore. The Mondoo scanner roles have the same policy.
  2. Wait a few minutes. Then check that the instance reports online to SSM:

    aws ssm describe-instance-information --region <region> \
      --filters "Key=InstanceIds,Values=<instance-id>" \
      --query "InstanceInformationList[].PingStatus"

    If the output shows Online, the subnet gives the scanner access to SSM. In the AWS Systems Manager console, the instance also shows up as a managed node in Fleet Manager.

  3. If the output is empty, the instance can't reach SSM. Check these:

    • The route table of the subnet.
    • The outbound rules of the security group and the network ACL of the subnet.
    • DNS resolution of ssm.<region>.amazonaws.com in the VPC. A custom DNS server must forward amazonaws.com queries to the VPC's Amazon DNS server.
    • Any firewall on the route. It must allow HTTPS to ssm.<region>.amazonaws.com, ssmmessages.<region>.amazonaws.com, and ec2messages.<region>.amazonaws.com.
  4. Terminate the test instance.

Logging and metrics

Lambda logs go to CloudWatch under the log group /aws/lambda/MondooLambdaLogGroup in the install region. The Updater Lambda logs to /aws/lambda/MondooUpdaterLogGroup. Open the log group and use Search Log Group to query messages or filter by time range.

AWS CloudWatch Log Group Details Console

Enable debug logging

Add the environment variable DEBUG=1 to the MondooLambda function in the AWS Lambda console.

Lambda Console

Send diagnostics or metrics to Mondoo

If you're working with Mondoo support, you can share Lambda diagnostics and metrics from the integration page:

Actions menu on a serverless AWS integration page in Mondoo, with Send ping, Send metrics, Send diagnostics data, Pause, and Copy MRN

  1. Open the AWS integration.
  2. In the top-right corner, select the ... (more integration actions) button.
  3. Select Send metrics or Send diagnostics data.

To check that Mondoo can reach the Lambda at all, select Send ping from the same menu.

403 errors with Terraform

The Terraform aws_iam_policy_attachment resource creates exclusive attachments. Per HashiCorp's guidance:

Across the entire AWS account, all of the users/roles/groups to which a single policy is attached must be declared by a single aws_iam_policy_attachment resource. This means that even any users/roles/groups that have the attached policy via any other mechanism (including other Terraform resources) will have that attached policy revoked by this resource.

If you attach a managed policy that Mondoo also uses to a role you manage with Terraform, Terraform revokes the attachment from Mondoo's role. Use a non-exclusive resource instead:

  • aws_iam_role_policy_attachment
  • aws_iam_user_policy_attachment
  • aws_iam_group_policy_attachment

Advanced debugging

The CloudFormation stack can always be deleted and recreated without data loss.

The Lambda function checks in with Mondoo Platform every 10 minutes. After an hour without a check-in, the integration's status changes to Missing and the integration page shows a No Recent Activity banner with a link to the stack in the AWS CloudFormation console. To learn what each status means, read Integration Status and Troubleshooting.

If the status is not Active:

  • Select Send ping from the ... menu on the integration page to check that Mondoo can reach the Lambda, then try RUN SCAN.
  • Check the CloudFormation stack status and the CloudWatch logs.
  • Confirm the Mondoo authentication settings are present in the SSM Parameter Store of the install region. If the Authentication row on the integration page shows Workload Identity Federation, look for the MondooWifConfig parameter. If it shows Service account (as for an AWS Organization install), look for MondooAgentConfig. To learn more, read How do AWS and Mondoo communicate?
  • Confirm the EventBridge rule mondoo-customevent-lambda-rule exists.

Still stuck? Email support@mondoo.com or join the Mondoo Community Slack.

Next steps

Last updated on

On this page