This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
ec2 = boto3.resource('ec2', region_name='us-east-1') | |
def lambda_handler(event, context): | |
instances = ec2.instances.filter(Filters=[ | |
{ | |
'Name': 'instance-state-name', | |
'Values': ['running'] | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
ec2 = boto3.resource('ec2', region_name='us-east-1') | |
def lambda_handler(event, context): | |
instances = ec2.instances.filter(Filters=[ | |
{ | |
'Name': 'instance-state-name', | |
'Values': ['stopped'] | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
dynamodb = boto3.resource('dynamodb', region_name='us-east-1') | |
table = dynamodb.Table('LUDreamCar') | |
with open("dreamcardata.json") as json_file: | |
dreamcardata = json.load(json_file) | |
for dreamcar in dreamcardata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
dynamodb = boto3.resource('dynamodb', region_name='us-east-1') | |
table = dynamodb.create_table( | |
TableName='LUDreamCar', | |
KeySchema=[ | |
{ | |
'AttributeName': 'brand', | |
'KeyType': 'HASH' #Partition key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### dynamodb/variables.tf | |
variable "aws_region" { | |
description = "The region where the instance will be deployed to" | |
type = string | |
default = "us-east-1" | |
} | |
variable "table_name" { | |
description = "Dynamodb table name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### --- dynamodb/resources.tf --- | |
resource "aws_dynamodb_table" "sneakers_table" { | |
name = var.table_name | |
read_capacity = 20 | |
write_capacity = 20 | |
hash_key = "BrandName" | |
range_key = "ModelNumber" | |
attribute { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### --- dynamodb/providers.tf --- | |
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.27" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### --- week8.5 root/dynamo.tf --- | |
module "dynamodb_table" { | |
source = "./dynamodb" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "instance" { | |
source = "./ec2" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### --- ec2/variables.tf --- | |
variable "region" { | |
description = "The region where the instance will be deployed to" | |
type = string | |
default = "us-east-1" | |
} | |
variable "ami" { | |
description = "AMI ID" |
NewerOlder