putParameter method

Future<PutParameterResult> putParameter({
  1. required String name,
  2. required String value,
  3. String? allowedPattern,
  4. String? dataType,
  5. String? description,
  6. String? keyId,
  7. bool? overwrite,
  8. String? policies,
  9. List<Tag>? tags,
  10. ParameterTier? tier,
  11. ParameterType? type,
})

Create or update a parameter in Parameter Store.

May throw HierarchyLevelLimitExceededException. May throw HierarchyTypeMismatchException. May throw IncompatiblePolicyException. May throw InternalServerError. May throw InvalidAllowedPatternException. May throw InvalidKeyId. May throw InvalidPolicyAttributeException. May throw InvalidPolicyTypeException. May throw ParameterAlreadyExists. May throw ParameterLimitExceeded. May throw ParameterMaxVersionLimitExceeded. May throw ParameterPatternMismatchException. May throw PoliciesLimitExceededException. May throw TooManyUpdates. May throw UnsupportedParameterType.

Parameter name : The fully qualified name of the parameter that you want to create or update. The fully qualified name includes the complete hierarchy of the parameter path and name. For parameters in a hierarchy, you must include a leading forward slash character (/) when you create or reference a parameter. For example: /Dev/DBServer/MySQL/db-string13

Naming Constraints:

  • Parameter names are case sensitive.
  • A parameter name must be unique within an Amazon Web Services Region
  • A parameter name can't be prefixed with "aws" or "ssm" (case-insensitive).
  • Parameter names can include only the following symbols and letters: a-zA-Z0-9_.-

    In addition, the slash character ( / ) is used to delineate hierarchies in parameter names. For example: /Dev/Production/East/Project-ABC/MyParameter

  • Parameter names can't contain spaces. The service removes any spaces specified for the beginning or end of a parameter name. If the specified name for a parameter contains spaces between characters, the request fails with a ValidationException error.
  • Parameter hierarchies are limited to a maximum depth of fifteen levels.
For additional information about valid values for parameter names, see Creating Systems Manager parameters in the Amazon Web Services Systems Manager User Guide.

Implementation

Future<PutParameterResult> putParameter({
  required String name,
  required String value,
  String? allowedPattern,
  String? dataType,
  String? description,
  String? keyId,
  bool? overwrite,
  String? policies,
  List<Tag>? tags,
  ParameterTier? tier,
  ParameterType? type,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.PutParameter'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'Value': value,
      if (allowedPattern != null) 'AllowedPattern': allowedPattern,
      if (dataType != null) 'DataType': dataType,
      if (description != null) 'Description': description,
      if (keyId != null) 'KeyId': keyId,
      if (overwrite != null) 'Overwrite': overwrite,
      if (policies != null) 'Policies': policies,
      if (tags != null) 'Tags': tags,
      if (tier != null) 'Tier': tier.value,
      if (type != null) 'Type': type.value,
    },
  );

  return PutParameterResult.fromJson(jsonResponse.body);
}