Initiating an AWS CloudFormation Hooks project
The first step in creating your Hooks project is to initiate the project. You can use the
CloudFormation CLI init
command to initiate your Hooks project.
The init
command launches a wizard that walks you through setting up the project,
including a Hooks schema file. Use this schema file as a starting point for defining the shape
and semantics of your Hooks. For more information about Hook schemas, see
Schema.
To inititate a Hook project:
-
Create a directory for the project.
mkdir
~/mycompany-testing-mytesthook
-
Navigate to the new directory.
cd
~/mycompany-testing-mytesthook
-
Use the CloudFormation CLI
init
command to initiate the project.cfn init
The command returns the following output.
Initializing new project
-
The
init
command launches a wizard that walks you through setting up the project. When prompted, enterh
to specify a Hooks project.Do you want to develop a new resource(r) a module(m) or a hook(h)?
h
Enter a a name for your Hook type.
What's the name of your hook type? (Organization::Service::Hook)
MyCompany
::Testing
::MyTestHook
If only one language plugin is installed, it is selected by default. If more than one language plugin is installed, you can choose your desired language. Enter a number selection for the language of your choice.
Select a language for code generation: [1] java [2] python38 [3] python39 (enter an integer):
-
Set up packaging based on chosen development lanaguage.
Results: You have successfully initiated the project and have generated the files needed to develop a Hook. The following is an example of the directories and files that make up a Hooks project for Python 3.8.
mycompany-testing-mytesthook.json rpdk.log README.md requirements.txt hook-role.yaml template.yml docs README.md src __init__.py handlers.py models.py target_models aws_s3_bucket.py
Note
The files in the src
directory are created based on your language
selection. There are some useful comments and examples in the generated files. Some files, such
as models.py
, are automatically updated in a later step when you run the
generate
command to add runtime code for your handlers.