Attini quick start¶
In this guide we will:
Create a
hello-word
Attini projectCreate an Attini distribution from the project
Deploy the Attini distribution to
stage
Deploy the Attini distribution to
production
Before you start, you need an AWS Account and the AWS CLI (with configured credentials). Attini uses your existing AWS credentials so you have to be logged in.
Note
The Attini Framework will get configuration appropriate for a Sandbox environment. To do a proper installation, please see installing the Attini CLI and Install Attini Framework.
Get started¶
Verify your AWS Credentials
aws sts get-caller-identity
Create a working directory
mkdir -p attini-hello-world
cd attini-hello-world
The next step is to install the Attini CLI and the Attini Framework
Install the Attini CLI¶
The Attini CLI is available for macOS and Linux. For Windows users, we recommend WSL or a virtual machine.
Download the CLI
rm -f /usr/local/bin/attini; curl -L#o /usr/local/bin/attini https://docs.attini.io/api/v1/cli/get-cli/$(uname -m)/$(uname -s)/latest; chmod +x /usr/local/bin/attini
If you don’t want to do an Admin/Root installation or if you have any other issues with the installation, find alternatives and more details here.
Verify the installation
attini --version
Enable autocomplete
source <(attini generate-completion)
Enable autocomplete in future shells
RC_FILE=~/."${SHELL##*/}"rc;
echo 'source <(attini generate-completion)' >> $RC_FILE;
Onboard the Attini Framework¶
This step takes about 4 min
attini setup --accept-license-agreement --create-deployment-plan-default-role --create-init-deploy-default-role
Note
If you get the error Text {date} could not be parsed at index 19
please see our common issues.
For more information about the options, please see Install the Attini Framework.
Initiate and deploy a project¶
The hello-world
project (when deployed) will create an AWS SSM Parameter,
a Lambda function that reads the Parameter, and an API Gateway that triggers the Lambda. The SSM parameter
will contain different values depending on what environment the project is deployed to. This is because of how
the attini-config.yaml
is configured.
Solution architecture
Deploy process
Initiate a hello-world project
attini init-project hello-world
Create a distribution from the project
attini package .
Find more information about attini package here.
Deploy your Attini distribution to stage
attini environment create stage
This command tells Attini that it’s ok to deploy to stage
in this AWS Account and Region. This is just a safety feature to avoid
human errors, therefore, creating and removing environments are harmless operations that will only allow or forbid future deployments.
It will never affect any of your running AWS resources.
attini deploy run attini_dist/hello-world.zip -e stage
Attini will now run the init deployment and execute the deployment plan.
Test the endpoint
STAGE_ENDPOINT=$(aws cloudformation describe-stacks --stack-name stage-hello-world-lambda --query 'Stacks[0].Outputs[?OutputKey==`Endpoint`].OutputValue' --output text)
echo $STAGE_ENDPOINT
curl $STAGE_ENDPOINT
This script reads the CloudFormation output from our ${environment}-hello-world-lambda
stack which contains our API Gateways endpoint.
Then it prints the endpoint (URL) and calls it using curl
.
Deploy to production
Now we want to create a new environment (in this example we create a production
environment) and deploy the same distribution to it.
So we will run the same commands as we did above, but with the environment name production
:
attini environment create production
attini deploy run attini_dist/hello-world.zip -e production
Test the endpoint
PRODUCTION_ENDPOINT=$(aws cloudformation describe-stacks --stack-name production-hello-world-lambda --query 'Stacks[0].Outputs[?OutputKey==`Endpoint`].OutputValue' --output text)
echo $PRODUCTION_ENDPOINT
curl $PRODUCTION_ENDPOINT
Check your deployments
Now that we deployed the same distribution to two different environments we can use the context
command to get an overview of our different environments:
attini context
The output should look something like this:
attiniVersion: "X.X.X"
account: "111111111111"
user: "arn:aws:sts::111111111111:assumed-role/role-name/xxxxxxxx"
region: "eu-west-1"
environments:
- environmentName: "prod"
distributions:
- name: "hello-world"
distributionId: "YYYY-MM-DD_HH:MM:SS"
deploymentPlans:
- name: "AttiniDeploymentPlanSfnHelloWorldDeploymentPlan-xxxxxxxxxxxx"
lastStatus: "SUCCEEDED"
lastExecutionStart: "2022-01-01 01:01:01"
- environmentName: "stage"
distributions:
- name: "hello-world"
distributionId: "YYYY-MM-DD_HH:MM:SS"
deploymentPlans:
- name: "AttiniDeploymentPlanSfnHelloWorldDeploymentPlan-xxxxxxxxxxxx"
lastStatus: "SUCCEEDED"
lastExecutionStart: "2022-01-01 01:05:01"
You can easily see:
What environments you have in this AWS Account and Region.
What distributions you have in every environment.
The distribution id tells us if the environments are on the same version.
Conclusion and next steps¶
We have created a straightforward hello-world example using Attini and deployed it to two different environments.
It was then very easy to compare the configuration of our environments using the
attini context
command.To do this, Attini only used your AWS credentials, and the deployment was done using serverless resources inside of your AWS Account, removing any dependency on a central CI/CD tool.
Your current CI/CD tools are easily extended with Attini, you just have to install the Attini CLI on your worker nodes.
The Attini way of working provides many advantages, so please keep on experimenting!
If you need any support or have feedback, please send us an email at
support@attini.io
.
Next step¶
To start using Attini for you projects, see the getting started guide.
Clean up¶
Below is a script that will delete everything from the guide above. If you have added your own stacks or deployed to other environments, please adjust the script accordantly.
attini environment remove stage
attini environment remove production
aws cloudformation delete-stack --stack-name stage-hello-world-lambda
aws cloudformation delete-stack --stack-name stage-hello-world-parameter
aws cloudformation delete-stack --stack-name stage-hello-world-deployment-plan
aws cloudformation delete-stack --stack-name production-hello-world-lambda
aws cloudformation delete-stack --stack-name production-hello-world-parameter
aws cloudformation delete-stack --stack-name production-hello-world-deployment-plan
aws ssm delete-parameters --names /attini/distributions/stage/hello-world/latest /attini/distributions/production/hello-world/latest /attini/environments
To remove the Attini Framework please see Deleting/Clean up the Attini Framework.
To uninstall the Attini CLI please see Uninstall the Attini CLI.