Dev Tools Flashcards
What are the 6 sections of CloudFormation
AWSTEmplateFormationVersion - “2010-09-09” -> Internal AWS use.
Description - Comments about the Template itself.
Resources (MANDATORY) - AWS Resources to create
Parameters - Dyanminc Inputs
Mappings - Static Variables for Template
Outputs - What has been created
Conditions - Conditions to perform resource creation.
WHen to use CDK
CDK - Cloud Dev Kit sits on top of Cloud Formation and lets you build your own infrastructure using common programming languages such as java/python/.NET
Which type of credenytials CANNOT be used by CodeCommit ?
IAM username and password - IAM username and password credentials cannot be used to access CodeCommit.
How to stop long running CodeBuild jobs?
Enable CodeBuild timeouts
When possible, builds run concurrently. The maximum number of concurrently running builds can vary.
Builds are queued if the number of concurrently running builds reaches its limit. The maximum number of builds in a queue is five times the concurrent build limit.
A build in a queue that does not start after the number of minutes specified in its time out value is removed from the queue. The default timeout value is eight hours. You can override the build queue timeout with a value between five minutes and eight hours when you run your build.
By setting the timeout configuration, the build process will automatically terminate post the expiry of the configured timeout.
What does Transform in CloudFormation imply?
Presence of Transform section indicates it is a Serverless Application Model (SAM) template
What are the CodeDeploy hooks?
Start
ApplicastionStop
DOwnbloadBundle
BeforeINstall
Install
AfterInstall
ApplicatioSTart
ValidateService
End
apsec.yml v buildspec.yml
????
deployment to Elastic Beanstalk is taking a very long time due to resolving dependencies on all of your 100 target EC2 instances. what can you do to improve time.
Bundle the dependencies in the source code during the build stage of CodeBuild
What is CodeDeploy Agent
“CodeDeploy Agent”
The CodeDeploy agent is a software package that, when installed and configured on an instance, makes it possible for that instance to be used in CodeDeploy deployments. The CodeDeploy agent archives revisions and log files on instances. The CodeDeploy agent cleans up these artifacts to conserve disk space. You can use the :max_revisions: option in the agent configuration file to specify the number of application revisions to the archive by entering any positive integer. CodeDeploy also archives the log files for those revisions. All others are deleted, except for the log file of the last successful deployment.
Immutable deploy v blue green
The main difference is that in the immutable update, the new instances serve traffic alongside the old ones, while in the blue/green this doesn’t happen (you have an instant complete switch from old to new)
Blue/Green = new environment. New load balancer. DNS switch.
Immutable = new ASG alongside old one. Then terminates old one.
How does CodeBuild scale?
AWS CodeBuild is a fully managed build service in the cloud. CodeBuild compiles your source code, runs unit tests, and produces artifacts that are ready to deploy. CodeBuild eliminates the need to provision, manage, and scale your own build servers. It provides prepackaged build environments for popular programming languages and build tools such as Apache Maven, Gradle, and more. You can also customize build environments in CodeBuild to use your own build tools. CodeBuild scales automatically to meet peak build requests.
If CloudFormation doesnt support a resource, how do you get around it ?
Use Custom Resource
You want to create a CloudFormation stack in multiple AWS accounts in multiple AWS Regions. What is the easiest way to achieve this?
CF StackSets
What are Cloud FOrmation PSUEDO PARAMETERS
These are fixed parameters available by default. Examples:
AWS::AccountId
AWS::Region
AWS::
How to use CF Mappings?
Mappings are like dictionaries
Parameters:
MyType:
Type: String
AllowedValues:
- t2.micro
- t3.micro
Default: t2.micro
InstanceType: !Ref MyType
How to use CF Outputs as inputs to other resources ?
Export and ImportValue
Outputs:
BlahBlah:
Description: This is some output
Value: !Ref MyCompanySG
Export:
Name: SSHSG
This can then be referenced from other resource using the !ImportValue function
SecurityGroups:
!ImportValule SSHSG
CF Intrisic Functions
Build in functions such as
!GetAtt -> Return specific attributes of a resource. !GetAtt MYE2Instance.AvaialibiltyZone
!FindInMap [map, TopKey, SecondKey]
!ImportValue - Import values
!Bas64 - COnver string to Base64. Eg to pass encoded data to EC2 instance.
Conditions And/Equals/If/Not/Or
CF Deletion Policy
Control what happens when the CF template is deleted. Default DeletionPolicy is Delete.
Note: S3 buckets will FAIL if you try to delete the S3 without first emptying it.
DeletionPolicy: Retain -> Prevents a pacific resource from being deleted if template is destroyed.
DeletionPolicy: Snapshot -> Create a final snapshot before deleting resource
If user needs to select a value from Cloud FOrmation from list of approved types ……
AllowedValues inside Parameter
Lookup a value from dictionary such as AMI type in CF ?
Mappings and !FindInMap[ myMap, Key1, Key2]
aws cli useful commands
S3
aws s3 ls
aws s3 cp s3://steve-app-bucket/demo.py /apps/demo.py
Lambda
aws lambda list-functions
Sync Call
aws lambda invoke –function-name demo-lambda-python –cli-binary-format raw-in-base64-out –payload ‘{“key1”: “lilly”, “key2”: “olivia”, “key3”:”jack”}’ response.json
Asycn Call
aws lambda invoke –function-name demo-lambda-python –cli-binary-format raw-in-base64-out –payload ‘{“key1”: “lilly”, “key2”: “olivia”, “key3”:”jack”}’ –invocation-type Event response.json
SQS
aws sqs list-queues
aws sqs send-message –queue-url https://sqs.eu-west-2.amazonaws.com/8681…. –message-body “Hello Steve”
aws sqs receive-message –queue-url https://sqs.eu-west-2.amazonaws.com/8681
aws sqs delete-message –queue-url xxxxxx –receipt-handle yyyyyy
Iam
aws iam list-users
ec2
aws ec2 monitor-instances –instance-ids i-1234567890abcdef0 - MOnitor ec2 instance(s)
Codedeploy inplace run order
Application Stop -> Before Install -> Application Start -> ValidateService
CodeDEploy In-Place v BlueGreen deploy
In-place Deployment
The application on each instance in the deployment group is stopped, the latest application revision is installed, and the new version of the application is started and validated. You can use a load balancer so that each instance is deregistered during its deployment and then restored to service after the deployment is complete.
Blue/green Deployment
With a blue/green deployment, you provision a new set of instances on which CodeDeploy installs the latest version of your application. CodeDeploy then re-routes load balancer traffic from an existing set of instances running the previous version of your application to the new set of instances running the latest version. After traffic is re-routed to the new instances, the existing instances can be terminated.