AWS
MissingParameter - Missing Parameter
Hitting a **MissingParameter** error means your AWS API request is missing a required parameter—AWS usually specifies which parameter is missing in the error message. This client-side error (4xx) happens when AWS validates request parameters. Most common when EC2 run-instances is missing ImageId or InstanceType, but also appears when parameter names are misspelled, nested parameters are missing, conditional parameters are required but not provided, or parameters are in the wrong location in the request.
#Common Causes
- →Identity: IAM policy parameter restrictions. Service Control Policy (SCP) requires specific parameters.
- →Network: VPC endpoint parameter requirements. API Gateway parameter validation.
- →Limits: Required parameter not provided. Parameter name misspelled (case-sensitive). Nested parameter missing (e.g., Placement.AvailabilityZone). Conditional parameter required (e.g., if using Spot, need SpotPrice). Parameter in wrong location.
✓Solutions
- 1Step 1: Diagnose - Check exact error message: AWS usually specifies which parameter is missing. Review error message for parameter name. Check if parameter name is misspelled.
- 2Step 2: Diagnose - Use AWS CLI help to see required parameters: aws ec2 run-instances help. Review required vs optional parameters. Check parameter names (case-sensitive).
- 3Step 3: Diagnose - Validate request structure: Check if nested parameters are correct (e.g., Placement.AvailabilityZone). Verify conditional parameters (e.g., Spot instances require SpotPrice). Check parameter location in request.
- 4Step 4: Fix - Review API documentation: Check AWS API Reference for exact parameter names. Verify required parameters for your operation. Check for conditional requirements.
- 5Step 5: Fix - Include all required parameters: Add missing parameter to request. Verify parameter name spelling. Check nested parameter structure. Test with minimal required parameters first.
</>Code Examples
Use AWS CLI Help to Find Required Parameters
1#!/bin/bash
2# Get help for EC2 run-instances to see required parameters
3echo "=== EC2 Run Instances Required Parameters ==="
4aws ec2 run-instances help | grep -A 20 "SYNOPSIS"
5
6# Check specific required parameters
7echo "\n=== Required Parameters ==="
8aws ec2 run-instances help | grep -i "required" | head -10
9
10# Example: Check what's required for run-instances
11echo "\n=== Testing with Minimal Required Parameters ==="
12AMI_ID="ami-xxxxx" # Replace with valid AMI
13INSTANCE_TYPE="t2.micro"
14
15# Minimal required parameters
16aws ec2 run-instances \
17 --image-id ${AMI_ID} \
18 --instance-type ${INSTANCE_TYPE} \
19 --count 1 \
20 --dry-run 2>&1 | head -5
21
22# If error says missing parameter, check help
23echo "\nIf MissingParameter error, check:"
24echo "aws ec2 run-instances help | grep -A 5 PARAMETER_NAME"Validate Required Parameters Before Request
1#!/bin/bash
2# Function to check required parameters
3check_required_params() {
4 local params="$@"
5 local missing=()
6
7 # Required for EC2 run-instances
8 if [[ ! "${params}" =~ ImageId ]]; then
9 missing+=("ImageId")
10 fi
11 if [[ ! "${params}" =~ InstanceType ]]; then
12 missing+=("InstanceType")
13 fi
14
15 if [ ${#missing[@]} -gt 0 ]; then
16 echo "✗ Missing required parameters: ${missing[*]}"
17 return 1
18 else
19 echo "✓ All required parameters present"
20 return 0
21 fi
22}
23
24# Example usage
25echo "=== Validating Parameters ==="
26PARAMS="--image-id ami-xxxxx --instance-type t2.micro"
27check_required_params "${PARAMS}"
28
29# Test actual command
30if check_required_params "${PARAMS}"; then
31 echo "\n=== Running Command ==="
32 aws ec2 run-instances ${PARAMS} --count 1 --dry-run 2>&1 | head -3
33fiCheck Nested and Conditional Parameters
1#!/bin/bash
2# Example: EC2 run-instances with nested parameters
3AMI_ID="ami-xxxxx"
4INSTANCE_TYPE="t2.micro"
5
6echo "=== Testing with Nested Parameters ==="
7# Placement is a nested parameter (Placement.AvailabilityZone)
8AVAILABILITY_ZONE="us-east-1a"
9
10aws ec2 run-instances \
11 --image-id ${AMI_ID} \
12 --instance-type ${INSTANCE_TYPE} \
13 --placement AvailabilityZone=${AVAILABILITY_ZONE} \
14 --count 1 \
15 --dry-run 2>&1 | head -5
16
17# Example: Conditional parameters (Spot instances require SpotPrice)
18echo "\n=== Conditional Parameters (Spot Instances) ==="
19echo "If using Spot instances, SpotPrice is required:"
20echo "aws ec2 run-instances \"
21echo " --image-id ${AMI_ID} \"
22echo " --instance-type ${INSTANCE_TYPE} \"
23echo " --instance-market-options '{"MarketType":"spot","SpotOptions":{"SpotInstanceType":"one-time","MaxPrice":"0.05"}}' \"
24echo " --count 1"↗Related Errors
Provider Information
This error code is specific to AWS services. For more information, refer to the official AWS documentation.