This is an example project on how to get started with Amplify plugin development. I will be documenting everything that I have found that helps make a successful plugin.
This repo will create a category on Amplify called example.
It has two commands:
- Add
Will stage an example for amplify
- Remove
Will remove the project from amplify
These are implemented in two stages:
- commands/example/<command_name>.js:
Goes into the context variable that is defined in the extension folder
- extensions/example-<command_name>.js: Modules exports
Exports the function to the context variable. (These exports need to be unique). This should point to a private function that would run the needed functions in this file.
CategoryName
: Name of your category
ProjectName
: Name of the category project (This is set by the user)
Options
: See Appendix 1 - Options
N/A
CategoryName
: Name of your category
ProjectName
: Name of the category project (This is set by the user)
OptionKey
: Key of option you want to update in the dictionary
OptionValue
: Value of option you want to update in the dictionary
N/A
N/A
{
providers:{
//Populated from amplify init cloudformation setup
awscloudformation:{
AuthRoleName,
UnauthRoleArn,
AuthRoleArn,
Region,
DeploymentBucketName,
UnauthRoleName,
StackName,
StackId
}
},
[. . .]
<plugin-name>:{
<project-name>: {
// Populated from the options variable sent in.
service,
providerPlugin,
[ . . . ]
//Populated only after push
providerMetadata, //Info needed for the provider
lastPushTimeStamp, //Last push info
output, //Outputs from the provider plugin
lastPushDirHash //Hash of last push to detect changes
}
}
}
N/A
{
//Overall Project Name
projectName,
version,
//Frontend hooks (good for codegen)
frontend,
<frontend_value>:{
framework,
config:{
SourceDir,
DistributionDir,
BuildCommand,
StartCommand
}
},
//Array of configured providers (just names)
providers
}
N/A
String
- Full location to the amplify/backend
for the project
Context
: Context variable that contains amplify
CopyJobs
: Dictionary of files to copy to the backend folder. This takes advantage of .ejs which allows you to write variables from the Props input to the file. You can use this with both YAML and JSON
Example:
copyJobs = [
{
dir: __dirname,
//Template location that is ejs format (from the dir level)
template,
//Location to copy to (direct path)
//i.e. /<backend_location>/<category_name>/<project_name>/<unique-template-name>
target,
}
];
Props
: Dictionary of variables that you want to go into your CopyJob
N/A
Context
: Context variable that contains amplify
CategoryName
: Name of your category
ProjectName
: Name of the category project (This is set by the user)
N/A
Required in options:
{
service,
providerPlugin
};
service
: Name of your category
providerPlugin
: Name of your cloud provider (i.e awscloudformation
)
Notice: You can have more options but these are the only required