Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Wasita andreaswasita

View GitHub Profile
View lab1-bastion_stack.json
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Add a bastion host to an existing VPC. VPC must have an internet gateway already. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
"MinLength": "1",
View Outputs_JSON
"Outputs" : {
"PrivateRouteTableId" : {
"Value" : {"Ref" : "PrivateRouteTable"},
"Description" : "Private Route Table ID"
}
}
}
View Resources_JSON
"Resources" : {
"NATIPAddress" : {
"Type" : "AWS::EC2::EIP",
"Properties" : {
"Domain" : "vpc",
"InstanceId" : { "Ref" : "NATDevice" }
}
},
View Mappings_JSON
"Mappings" : {
"AWSNATAMI": {
"us-east-1": {"AMI": "ami-6e9e4b06"},
"us-west-2": {"AMI": "ami-8b6912bb"},
"us-west-1": {"AMI": "ami-1d2b2958"},
"eu-west-1": {"AMI": "ami-14913f63"},
"ap-northeast-1": {"AMI": "ami-27d6e626"}
}
},
View Parameters_JSON
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
},
View JSON_Headers
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Builds a VPC w/ INET Gateway and 3 public subnets. **WARNING** This template creates Amazon EC2 instance(s). You will be billed for the AWS resources used if you create a stack from this template.",
View lab1-vpc_ELB_combined.json
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Builds a VPC w/ INET Gateway and 3 public subnets. **WARNING** This template creates Amazon EC2 instance(s). You will be billed for the AWS resources used if you create a stack from this template.",
"Resources" : {
"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
View Stop-AzureVMonSchedule.ps1
<#
.Synopsis
Creates scheduled tasks to stop Virtual Machines.
.DESCRIPTION
Creates scheduled tasks to stop a single Virtual Machine or a set of Virtual Machines (using
wildcard pattern syntax for the Virtual Machine name).
.EXAMPLE
Stop-AzureVMsOnSchedule.ps1 -ServiceName "MyServiceName" -VMName "testmachine1" -TaskName "Stopt Test Machine 1" -At 5:30PM
Stop-AzureVMsOnSchedule.ps1 -ServiceName "MyServiceName" -VMName "test*" -TaskName "Stop All Test Machines" -At 5:30PM
#>
View Start-AzureVMonSchedule.ps1
<#
.SYNOPSIS
Creates scheduled tasks to start Virtual Machines.
.DESCRIPTION
Creates scheduled tasks to start a single Virtual Machine or a set of Virtual Machines (using
wildcard pattern syntax for the Virtual Machine name).
.EXAMPLE
Start-AzureVMsOnSchedule.ps1 -ServiceName "MyServiceName" -VMName "testmachine1" `
-TaskName "Start Test Machine 1" -At 8AM
View AzureNSG.ps1
#Create a Network Security Group
New-AzureNetworkSecurityGroup -Name "DMZ_NSG" -Location Southeast Asia -Label "DMZ NSG SEVNET"
#Add, Update Rules to a NSG
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Set-AzureNetworkSecurityRule -Name RDPInternet-DMZ -Type Inbound -Priority 347 -Action Allow -SourceAddressPrefix 'INTERNET' -SourcePortRange '63389' -DestinationAddressPrefix '10.0.2.0/25' -DestinationPortRange '63389' -Protocol TCP
#Delete a rule from NSG
Get-AzureNetworkSecurityGroup -Name "DMZ_NSG" | Remove-AzureNetworkSecurityRule -Name RDPInternet-DMZ
#Associate a NSG to a Virtual machine