-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from aligent/feature/MICRO-26_rework-match-ne…
…w-architecture MICRO-26: Rework to match new architecture
- Loading branch information
Showing
19 changed files
with
8,787 additions
and
9,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[{package.json,*.yml,*.md}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
jest.config.js | ||
vite.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"] | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier" | ||
], | ||
"rules": { | ||
"no-return-await": "off", | ||
"@typescript-eslint/return-await": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,22 @@ jobs: | |
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.release.target_commitish }} | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: git config --global user.name "Automated NPM Release" | ||
- run: git config --global user.email "[email protected]" | ||
- run: npm version ${{ github.event.release.tag_name }} --allow-same-version | ||
- run: npm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- run: git push | ||
env: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.release.target_commitish }} | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 18 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: git config --global user.name "Automated NPM Release" | ||
- run: git config --global user.email "[email protected]" | ||
- run: npm version ${{ github.event.release.tag_name }} --allow-same-version | ||
- run: npm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- run: git push | ||
env: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ jspm_packages | |
# Serverless directories | ||
.serverless | ||
|
||
# ESBuild directories | ||
# Build artifacts | ||
.build | ||
*.js | ||
*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16 | ||
v18.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore artifacts: | ||
.esbuild | ||
.serverless | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
singleQuote: true | ||
semi: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
# Serverless Magento | ||
|
||
A [Serverless framework](https://www.serverless.com) plugin for handling the registration of a Serverless application with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) module. | ||
A [Serverless framework](https://www.serverless.com) plugin for handling the registration of a microservices with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) module. | ||
|
||
## Why? | ||
|
||
Serverless applications registered with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) module will have a [Magento authentication token](https://devdocs.magento.com/guides/v2.4/get-started/authentication/gs-authentication-token.html) made available via [AWS SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html). This removes the need to manually create Magento integrations / access tokens for each Serverless application. The registration also provides the opportunity to create an "admin" interface within the Magento admin interface which can be used for managing the serverless application. | ||
Microservices registered with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) module will have a [Magento authentication token](https://devdocs.magento.com/guides/v2.4/get-started/authentication/gs-authentication-token.html) made available via [AWS SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html). This removes the need to manually create Magento integrations / access tokens for each service. The registration also provides the opportunity to create an "admin" interface within the Magento admin interface which can be used for managing the serverless application. | ||
|
||
## Admin Interface | ||
The admin interface is provided as a link to an externally hosed web application which is rendered in the Magento admin interface as an `iframe`. Authorisation context will be injected into the iframe when loaded. | ||
|
||
## Deployment | ||
The registration happens as part of the Serverless deploy. If for any reason the registration is not able to take place, the deployment will fail (before any change set has been deployed). | ||
|
||
The Serverless plugin will initially register with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) REST API. At this state the service is "registered" but not "active". A service does not become "active" until an admin user approves it. | ||
The admin interface is provided as a link to an externally hosed web application which is rendered in the Magento admin interface as an `iframe`. Authorisation context will be injected into the iframe when loaded. | ||
|
||
An "activator" Lambda function will be deployed along with the Serverless application which repeatedly checks if the service has been "activated" within Magento. Once this is done, any provided admin interface is created and the Magento access token is retrieved and stored within SSM for use by the application. | ||
|
||
![serverless output](/images/serverless_output.png) | ||
## Deployment | ||
|
||
The Serverless plugin will initially register with the [magento2-microservice-config](https://bitbucket.org/aligent/magento2-microservice-config) REST API. At this state the service is "registered" but not "active". A service does not become "active" until an admin user approves it. | ||
|
||
## Serverless configuration | ||
|
||
The plugin is configured within the `serverless.yaml` by providing configuration values. | ||
|
||
### Example | ||
``` | ||
### Example | ||
|
||
```yaml | ||
custom: | ||
magento: | ||
baseUrl: 'http://localhost' | ||
name: 'Test Service' | ||
adminInterfaces: | ||
- name: 'Configuration' | ||
app_url: 'https://example.com' | ||
serviceRegistration: | ||
magentoUrl: https://magento.domain.name | ||
magentoApiToken: ${ssm:/magento/api/access-token-for-registration} | ||
displayName: Service name that appears in Magento Admin | ||
description: Short description about the service | ||
appUrl: https://web-app-url.on.cloudfront | ||
permissions: | ||
- Magento_Backend::all | ||
``` | ||
### Variables | ||
| Variable | Usage | | ||
| --------------------- | ----------------------------------------------------------- | | ||
| baseUrl | The base URL - including scheme - of the Magento instance.| | ||
| name | The friendly name of the service.| | ||
| adminInterfaces | An array of {name, app_url} representing the admin interfaces to be exposed by Magento| | ||
|
||
| Variable | Usage | | ||
| ----------- | --------------------------------------------------------------------------------------- | | ||
| magentoUrl | The base URL - including scheme - of the Magento instance. | | ||
| displayName | The name of the application/service. | | ||
| description | Short description about the application/service. | | ||
| appUrl | The url to access webapp (Only applicable for webapp, other service does not need this) | | ||
| permission | Array of Magento permission. Webapp does not need this | |
Binary file not shown.
Oops, something went wrong.