Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

bug: Unsupported type: cloudformation #202

Open
marcarvar opened this issue Mar 29, 2022 · 2 comments
Open

bug: Unsupported type: cloudformation #202

marcarvar opened this issue Mar 29, 2022 · 2 comments

Comments

@marcarvar
Copy link

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.

@nmoutschen
Copy link
Contributor

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.

@marcarvar
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants