aws-serverless-ecommerce-platform icon indicating copy to clipboard operation
aws-serverless-ecommerce-platform copied to clipboard

bug: Unsupported type: cloudformation

Open marcarvar opened this issue 4 years ago • 2 comments

Hello,

Today, I wanted to reproduce this example on my AWS account following the repository guide. After fighting me a little with the installation of the dependencies, I have executed:

make all

In several parts of the execution output, the following error was shown:

Unsupported type: cloudformation

Usage: {PATH}/aws-serverless-ecommerce-platform/tools/lint TYPE SERVICE

This happens with all the Tools folder scripts.

Checking the scripts I see that the next code shows that output:

type tests_$TYPE | grep -q "function" &>/dev/null || {
    echo "Unsupported type: $TYPE"
    echo
    display_usage
    exit 1
}

The problem of this verification, to know if there is function, is the dependence of the language(locale) of the shell. In my case when having it in Spanish I have to change the "function" value for "función". Because in my case that command returns the following:

$ type check-deps_cloudformation
check-deps_cloudformation: es una función
check-deps_cloudformation () 
{ 
    dependencies=$(yq -r ' .dependencies[]? ' $service_dir/metadata.yaml);
    echo "$dependencies" | grep --color=auto -q \* && { 
        dependencies="$($ROOT/tools/services --exclude ${SERVICE})"
    };
    echo dependencies=$dependencies;
    for dependency in $dependencies;
    do
        stack_name=${DOMAIN:-ecommerce}-${ENVIRONMENT:-dev}-${dependency};
        aws cloudformation describe-stacks --stack-name $stack_name | jq -r ' .Stacks |
                map(
                    .StackStatus
                    | test("(CREATE_FAILED|ROLLBACK_IN_PROGRESS|ROLLBACK_COMPLETE|ROLLBACK_FAILED|DELETE_IN_PROGRESS|DELETE_COMPLETE|DELETE_FAILED)")
                    | not
                ) ' | grep --color=auto -q "true" && { 
            FOUND=true
        };
        if [ -z $FOUND ]; then
            echo "Stack $stack_name not found";
            stack_name=${DOMAIN:-ecommerce}-${dependency};
            aws cloudformation describe-stacks --stack-name $stack_name | jq -r ' .Stacks |
                    map(
                        .StackStatus
                        | test("(CREATE_FAILED|ROLLBACK_IN_PROGRESS|ROLLBACK_COMPLETE|ROLLBACK_FAILED|DELETE_IN_PROGRESS|DELETE_COMPLETE|DELETE_FAILED)")
                        | not
                    ) ' | grep --color=auto -q "true" && { 
                FOUND=true
            };
        fi;
        if [ -z $FOUND ]; then
            echo "Stack $stack_name not found";
            exit 1;
        fi;
    done
}

By making this change I have managed to advance in the deployment although I still have to solve some more mistake. I do not know if there is any alternative solution to make that check but at least there is a record of this error.

marcarvar avatar Mar 29 '22 18:03 marcarvar

Hey @marcarvar ! Thanks a lot for creating this issue.

Could you try this command to see if it outputs it into a localised format or not?

type -t check-deps_cloudformation

-t should only return the type (e.g. function), but I'm unsure if it localises it or not.

nmoutschen avatar Mar 30 '22 07:03 nmoutschen

Hello @nmoutschen, thank you for your quick answers.

With the -t option the result is not generated in a localized format. I attach the execution of the command in the same Bash instance:

~$ type -t check-deps_cloudformation
function
~$ type check-deps_cloudformation
check-deps_cloudformation: es una función
check-deps_cloudformation () 
{ 
    dependencies=$(yq -r ' .dependencies[]? ' $service_dir/metadata.yaml);
    echo "$dependencies" | grep --color=auto -q \* && { 
        dependencies="$($ROOT/tools/services --exclude ${SERVICE})"
    };
    echo dependencies=$dependencies;
    for dependency in $dependencies;
    do
        stack_name=${DOMAIN:-ecommerce}-${ENVIRONMENT:-dev}-${dependency};
        aws cloudformation describe-stacks --stack-name $stack_name | jq -r ' .Stacks |
                map(
                    .StackStatus
                    | test("(CREATE_FAILED|ROLLBACK_IN_PROGRESS|ROLLBACK_COMPLETE|ROLLBACK_FAILED|DELETE_IN_PROGRESS|DELETE_COMPLETE|DELETE_FAILED)")
                    | not
                ) ' | grep --color=auto -q "true" && { 
            FOUND=true
        };
        if [ -z $FOUND ]; then
            echo "Stack $stack_name not found";
            stack_name=${DOMAIN:-ecommerce}-${dependency};
            aws cloudformation describe-stacks --stack-name $stack_name | jq -r ' .Stacks |
                    map(
                        .StackStatus
                        | test("(CREATE_FAILED|ROLLBACK_IN_PROGRESS|ROLLBACK_COMPLETE|ROLLBACK_FAILED|DELETE_IN_PROGRESS|DELETE_COMPLETE|DELETE_FAILED)")
                        | not
                    ) ' | grep --color=auto -q "true" && { 
                FOUND=true
            };
        fi;
        if [ -z $FOUND ]; then
            echo "Stack $stack_name not found";
            exit 1;
        fi;
    done
}

With that change should be solved.

marcarvar avatar Mar 30 '22 08:03 marcarvar