Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed for use of array objects when describing additional stacks. #26

Merged
merged 2 commits into from
Sep 19, 2020
Merged

Allowed for use of array objects when describing additional stacks. #26

merged 2 commits into from
Sep 19, 2020

Conversation

EliteMasterEric
Copy link
Contributor

This pull request adds the functionality which checks if each additional stack is defined as an array rather than an object. If it is an array, it will be flattened, with the keys of each array object being combined into a final object.

The result is that complex stacks can be split into multiple files, like so:

custom:
  additionalStacks:
    permanent: 
        -${file(resources/s3.yml)}
        -${file(resources/meta.yml)}

Here is an example for the individual files:

s3.yml

Resources:
  S3LambdaInstance:
    Type: AWS::S3::Bucket

meta.yml

Deploy: After
StackName: persistent-data
Tags:
  Owner: [email protected]

The above example would thus render like so. Note the dashes, indicating that permanent is an array of objects, rather than an object containing keys:

custom:
  additionalStacks:
    permanent: 
        - Resources:
            S3LambdaInstance:
                Type: AWS::S3::Bucket
        - Deploy: After
          StackName: persistent-data
          Tags:
              Owner: [email protected]

With this pull request, using code adapted from Serverless Core's implementation of resource handling, any elements of additionalStacks which contain an array rather than an object will be flattened into an object, like so:

custom:
  additionalStacks:
    permanent: 
        Resources:
            S3LambdaInstance:
                Type: AWS::S3::Bucket
        Deploy: After
        StackName: persistent-data
        Tags:
            Owner: [email protected]

This pull request resolves issue #13, and adds a tertiary to the test suite to ensure the correct functionality.

@EliteMasterEric
Copy link
Contributor Author

There are two issues with the pull request as it stands, which I hope can be resolved.

  1. The functionality used to merge the array objects requires lodash, a rather large library. I will look into whether I can find a smaller alternative.
  2. I was not able to execute the tests successfully before or after the pull request's changes. I assume this issue is because of some unseen additional required configuration. I would appreciate it if you could ensure the test suite runs properly.

@EliteMasterEric
Copy link
Contributor Author

I have discovered the package lodash.merge and replaced the full lodash with that.

Again, if you can get the unit tests running, I'd love to see this merged promptly. Whenever I run the tests, I get a response of "stack does not exist" for every test.

@kennu
Copy link
Contributor

kennu commented Sep 19, 2020

Sorry to keep this waiting for a long time, looks like it's fully backwards compatible

@EliteMasterEric
Copy link
Contributor Author

Hey @kennu,

Since this pull request was completed, I have since resolved the issue by reworking the structure of my project to include a single stack which is deployed before all other stacks. As such, I no longer use this plugin myself.

However, I am certain that any other users who are looking to include this plugin in their projects will greatly appreciate the merging of this pull request, as well as request #28 .

Thank you for the hard work you are doing for the community!

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

Successfully merging this pull request may close these issues.

2 participants