Skip to content

Instantly share code, notes, and snippets.

@veevidify
Last active March 12, 2023 02:02
Show Gist options
  • Save veevidify/9dc164e7e17fded14e2db0d482a146c0 to your computer and use it in GitHub Desktop.
Save veevidify/9dc164e7e17fded14e2db0d482a146c0 to your computer and use it in GitHub Desktop.
Cloudy
#!/bin/bash
# CF
aws cloudformation deploy --template-file template.yaml --stack-name Ec2Ssh --parameter-overrides file://params.json
aws cloudformation delete-stack --stack-name Ec2Ssh
# ECR
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
docker tag hello-world:latest aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
[
{
"ParameterKey": "KeyName",
"ParameterValue": "YourKeyPairName"
}
]
AWSTemplateFormatVersion: 2010-09-09
Parameters:
KeyName:
Description: 'Ec2 key pair to ssh into the instance'
Type: 'AWS::EC2::KeyPair::KeyName'
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
SecurityGroups:
- !Ref InstanceSecurityGroup
KeyName: !Ref KeyName
ImageId: ami-0cdf84c392db3c246
InstanceSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: 'Allow ssh via port 22'
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment