src/main/java/com/digitalglobe/util/maven/plugin/CloudFormationDeployMavenPlugin.java
/**
     * This method process a Stack Output Parameter Mapping.  It saves the parameter to the specified array of
     * output parameters.  It also, if specified, saves the parameter to the System Manager Parameter Store.  It
     * uses the supplied ssmClient to write the parameters to the Parameter Store.
     *
     * @param outputParameters are the output parameters to save the parameter to.
     * @param ssmClient is the client to use when writing parameters to the parameter store.
     * @param parameterName is name of the parameter from the CloudFormation Template or CLI Command.
     * @param mapping is the mapping to process.
     * @param parameterValue is the value of the parameter.
     * @param region is the region to store the parameter.
     * @return a boolean indicating if the mapping was processed (It had no restrictions).
     * @throws MojoExecutionException when a processing error occurs in the method.
     * @throws IOException when the method is unable to read/write to the parameter store.
     */
This method process a Stack Output Parameter Mapping.  It saves the parameter to the specified array of
output parameters.  It also, if specified, saves the parameter to the System Manager Parameter Store.  It
uses the supplied ssmClient to write the parameters to the Parameter Store.

@param outputParameters are the output parameters to save the parameter to.
@param ssmClient is the client to use when writing parameters to the parameter store.
@param parameterName is name of the parameter from the CloudFormation Template or CLI Command.
@param mapping is the mapping to process.
@param parameterValue is the value of the parameter.
@param region is the region to store the parameter.
@return a boolean indicating if the mapping was processed (It had no restrictions).
@throws MojoExecutionException when a processing error occurs in the method.
@throws IOException when the method is unable to read/write to the parameter store.
This method process a Stack Output Parameter Mapping . It saves the parameter to the specified array of output parameters . It also if specified saves the parameter to the System Manager Parameter Store . It uses the supplied ssmClient to write the parameters to the Parameter Store . @param outputParameters are the output parameters to save the parameter to . @param ssmClient is the client to use when writing parameters to the parameter store . @param parameterName is name of the parameter from the CloudFormation Template or CLI Command . @param mapping is the mapping to process . @param parameterValue is the value of the parameter . @param region is the region to store the parameter . @return a boolean indicating if the mapping was processed ( It had no restrictions ) . @throws MojoExecutionException when a processing error occurs in the method . @throws IOException when the method is unable to read / write to the parameter store .
private Boolean ProcessMapping(Map<String, String> outputParameters, SsmClient ssmClient,
                                   String parameterName, String parameterValue, StackOutputParameterMapping mapping, String region)
            throws MojoExecutionException, IOException {
        Boolean noMappingRestrictions = true;
        if(mapping.condition != null) {
            if(!conditions.containsKey(mapping.condition))
                throw new MojoExecutionException("Condition doesn't exist in the conditions map.");
            noMappingRestrictions = conditions.get(mapping.condition);
        }
        String name = parameterName;
        if(noMappingRestrictions) {
            if(mapping.parameterStoreFieldName != null) {
                SsmClient client = ssmClient;
                if(mapping.roleArn != null) {
                    AwsCredentialsProvider session = getAwsCredentialsProvider(mapping.roleArn);
                    client = region != null ?
                            new ClientBuilder<SsmClient>().withRegion(region).build(ssmBuilder, session) :
                            new ClientBuilder<SsmClient>().build(ssmBuilder, session);
                }
                boolean update = false;
                try {
                    System.out.println("DEBUG: Getting Parameter: " + mapping.parameterStoreFieldName);
                    GetParameterRequest getParameterRequest = GetParameterRequest.builder()
                            .name(mapping.parameterStoreFieldName)
                            .withDecryption(true)
                            .build();
                    GetParameterResponse result = client.getParameter(getParameterRequest);
                    if(!result.parameter().value().trim()
                            .equals(parameterValue.trim())) {
                        update = true;
                    }
                } catch (ParameterNotFoundException ex)
                {
                    update = true;
                }
                if(update) {
                    System.out.println("DEBUG: Putting Parameter: " + name);
                    System.out.println("  With Parameter Type: " + mapping.parameterStoreFieldType);
                    if(mapping.parameterStoreFieldType != ParameterType.SECURE_STRING)
                        System.out.println("  With value: " + parameterValue);
                    System.out.println("  With Description: " + mapping.description);
                    System.out.println("  To: " + mapping.parameterStoreFieldName);
                    if(mapping.mapParameterName != null) System.out.println("And: " + mapping.mapParameterName);
                    System.out.println();
                    PutParameterRequest parameterRequest = PutParameterRequest.builder()
                            .name(mapping.parameterStoreFieldName)
                            .overwrite(true)
                            .description(mapping.description)
                            .type(mapping.parameterStoreFieldType.toString())
                            .value(parameterValue)
                            .build();
                    client.putParameter(parameterRequest);
                } else {
                    System.out.println("DEBUG: Output Parameter: " + name);
                    if(mapping.parameterStoreFieldType != ParameterType.SECURE_STRING)
                        System.out.println("  With value: " + parameterValue);
                    System.out.println("  With Description: " + mapping.description);
                    if( mapping.mapParameterName != null) System.out.println("  To: " + mapping.mapParameterName);
                    System.out.println();
                }
            } else {
                System.out.println("DEBUG: Output Parameter: " + name);
                System.out.println("  With value: " + parameterValue);
                System.out.println("  With Description: " + mapping.description);
                if( mapping.mapParameterName != null) System.out.println("  To: " + mapping.mapParameterName);
                System.out.println();
            }
            if(mapping.mapParameterName != null) name = mapping.mapParameterName;
            outputParameters.put(name, parameterValue.trim());
        }
        return noMappingRestrictions;
    }
private Boolean ProcessMapping ( Map < String , String > outputParameters , SsmClient ssmClient , String parameterName , String parameterValue , StackOutputParameterMapping mapping , String region ) throws MojoExecutionException , IOException { Boolean noMappingRestrictions = true ; if ( mapping . condition != null ) { if ( ! conditions . containsKey ( mapping . condition ) ) throw new MojoExecutionException ( "Condition doesn't exist in the conditions map." ) ; noMappingRestrictions = conditions . get ( mapping . condition ) ; } String name = parameterName ; if ( noMappingRestrictions ) { if ( mapping . parameterStoreFieldName != null ) { SsmClient client = ssmClient ; if ( mapping . roleArn != null ) { AwsCredentialsProvider session = getAwsCredentialsProvider ( mapping . roleArn ) ; client = region != null ? new ClientBuilder < SsmClient > ( ) . withRegion ( region ) . build ( ssmBuilder , session ) : new ClientBuilder < SsmClient > ( ) . build ( ssmBuilder , session ) ; } boolean update = false ; try { System . out . println ( "DEBUG: Getting Parameter: " + mapping . parameterStoreFieldName ) ; GetParameterRequest getParameterRequest = GetParameterRequest . builder ( ) . name ( mapping . parameterStoreFieldName ) . withDecryption ( true ) . build ( ) ; GetParameterResponse result = client . getParameter ( getParameterRequest ) ; if ( ! result . parameter ( ) . value ( ) . trim ( ) . equals ( parameterValue . trim ( ) ) ) { update = true ; } } catch ( ParameterNotFoundException ex ) { update = true ; } if ( update ) { System . out . println ( "DEBUG: Putting Parameter: " + name ) ; System . out . println ( "  With Parameter Type: " + mapping . parameterStoreFieldType ) ; if ( mapping . parameterStoreFieldType != ParameterType . SECURE_STRING ) System . out . println ( "  With value: " + parameterValue ) ; System . out . println ( "  With Description: " + mapping . description ) ; System . out . println ( "  To: " + mapping . parameterStoreFieldName ) ; if ( mapping . mapParameterName != null ) System . out . println ( "And: " + mapping . mapParameterName ) ; System . out . println ( ) ; PutParameterRequest parameterRequest = PutParameterRequest . builder ( ) . name ( mapping . parameterStoreFieldName ) . overwrite ( true ) . description ( mapping . description ) . type ( mapping . parameterStoreFieldType . toString ( ) ) . value ( parameterValue ) . build ( ) ; client . putParameter ( parameterRequest ) ; } else { System . out . println ( "DEBUG: Output Parameter: " + name ) ; if ( mapping . parameterStoreFieldType != ParameterType . SECURE_STRING ) System . out . println ( "  With value: " + parameterValue ) ; System . out . println ( "  With Description: " + mapping . description ) ; if ( mapping . mapParameterName != null ) System . out . println ( "  To: " + mapping . mapParameterName ) ; System . out . println ( ) ; } } else { System . out . println ( "DEBUG: Output Parameter: " + name ) ; System . out . println ( "  With value: " + parameterValue ) ; System . out . println ( "  With Description: " + mapping . description ) ; if ( mapping . mapParameterName != null ) System . out . println ( "  To: " + mapping . mapParameterName ) ; System . out . println ( ) ; } if ( mapping . mapParameterName != null ) name = mapping . mapParameterName ; outputParameters . put ( name , parameterValue . trim ( ) ) ; } return noMappingRestrictions ; }
This method process a Stack Output Parameter Mapping.
This method process a Stack Output Parameter Mapping .
// Check for mapping restriction by looking at the condition for executing the mapping. // If there are no restrictions and the parameter has a mapping, perform the mapping. // Store the parameter in System Manager Parameter Store if a field is specified. // Map the name if a mapping is specified. // Save the parameter to the output parameter array.