aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6.04k stars 1.23k forks source link

ValidationException: Parameter name: can't be prefixed with \"ssm\" #1952

Closed amcquade closed 4 years ago

amcquade commented 4 years ago

Please fill out the sections below to help us address your issue.

Version of AWS SDK for PHP?

Latest

Version of PHP (php -v)?

PHP 7.2.24

What issue did you see?

Error executing "PutParameter" on "https://ssm.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://ssm.us-east-1.amazonaws.com resulted in a 400 Bad Request response: Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of lette rs, numbers and the following 3 symbols .-_

Exception thrown is even when "ssm" isn't included in the parameter name. The first time this happened, I was using "smpt/support", however, I get failures using similar parameter names as well. Other failed parameter names:

Steps to reproduce

$p = [
    'Name' => '/myPrefix/xmpt/support@gmail.com',
    'Type' => 'String',
    'Value' => '12345',
    'Overwrite' => true
];

try {
    $result = $ssm->putParameter($p);
    if (!$result->hasKey('Errors')) {
        $success++;
    } else {
        var_dump($result->get('Errors'));
    }
} catch (\Aws\Ssm\Exception\SsmException $e) {
    $msg = $e->getMessage() . "\n";
    $msg .= $e->getAwsErrorType() . "\n";
    $msg .= $e->getAwsErrorMessage() . "\n";
    $msg .= $e->getAwsErrorCode() . "\n";
    $msg .= $e->getTraceAsString() . "\n";

    echo $msg;
}

Additional context

Using Parameter Store in Systems Manager.

amcquade commented 4 years ago

Im an idiot. @ symbol is not included in valid parameter name characters. Could improve exception response handling.

diehlaws commented 4 years ago

Hi @amcquade, thanks for reaching out to us. Unfortunately the error message you're seeing in this case is originating from the service rather than the SDK itself, as a result this isn't a behavior we can change from the SDK end. Given that this is a behavior of the service rather than the SDK, I'd suggest submitting a feature request for the service by posting on the AWS Forums for SSM, or reaching out to our Premium Support team by opening a new technical support case under the Systems Manager service and the Feature Request category.

cullylarson commented 1 year ago

In case anyone else finds this, I was getting this error because my parameter name didn't start with a /.