Skip to content

Instantly share code, notes, and snippets.

@awsvpc
awsvpc / lnx-connection.tf
Created March 15, 2024 23:05 — forked from rybons/lnx-connection.tf
Sample of Linux connection with bastion info
data "template_file" "lnx_script" {
template = "${file("${path.module}/templates/lnx_script.sh")}"
vars {
var1 = "${var.var1}"
}
}
resource "aws_instance" "myinstance" {
connection {
type = "ssh"
@awsvpc
awsvpc / SSM-ListInstanceIds.json
Last active February 11, 2024 02:45 — forked from lampidudelj/ChangeCognitoPassword.json
AWS Automation Document - Change Cognito Password
{
"schemaVersion": "0.3",
"description": "Updates a Microsoft Windows AMI. By default it will install all Windows updates, Amazon software, and Amazon drivers. It will then sysprep and create a new AMI. Supports Windows Server 2008 R2 and greater.",
"assumeRole": "{{ AutomationAssumeRole }}",
"parameters": {
"SourceAmiId": {
"type": "String",
"description": "(Required) The source Amazon Machine Image ID."
},
"TopicArn": {
@armenr
armenr / ssh_key.tf
Created November 21, 2022 12:01 — forked from irvingpop/ssh_key.tf
Terraform external data source example - dynamic SSH key generation
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
@thimslugga
thimslugga / lambda_function.py
Created September 8, 2022 12:55 — forked from thomasmichaelwallace/lambda_function.py
Lambda function to launch an ec2-instance
""" Lambda to launch ec2-instances """
import boto3
REGION = 'eu-central-1' # region to launch instance.
AMI = 'ami-24bd1b4b'
# matching region/setup amazon linux ami, as per:
# https://aws.amazon.com/amazon-linux-ami/
INSTANCE_TYPE = 'm3.medium' # instance type to launch.
EC2 = boto3.client('ec2', region_name=REGION)
@JAMSUPREME
JAMSUPREME / get-ec2.yaml
Last active February 11, 2024 02:14
SSM Automation
description: |-
### EC2 stopper by tag
Stop EC2 instances by tag
schemaVersion: '0.3'
mainSteps:
- name: getInstancesByTag
action: 'aws:executeAwsApi'
outputs:
- Name: InstanceIds
@p3x-robot
p3x-robot / linux-get-ipv6-address.sh
Created January 19, 2020 07:24
Linux IPv6 addresses
sudo ip addr show dev enp1s0f2 | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'
@keithduncan
keithduncan / buildkite_agent_step_function.json
Created March 5, 2019 11:19
An AWS step function to register and ping multiple virtual Buildkite agents.
{
"StartAt": "RegisterBuildkiteAgents",
"TimeoutSeconds": 1800,
"States": {
"RegisterBuildkiteAgents": {
"Type": "Pass",
"Result": {
"TaskDefinitions": {
"Definitions": [],
"Count": 0
@dalethestirling
dalethestirling / postgres_instance.tf
Created September 10, 2017 22:41
Using provisioner for RDS password generation
resource "aws_db_instance" "postgres" {
identifier = "${var.postgres_id}"
name = "${var.postgres_name}"
engine = "${var.postgres_engine}"
engine_version = "${var.postgres_version}"
multi_az = "${var.postgres_multi_az}"
instance_class = "${var.postgres_class}"
db_subnet_group_name = "${var.postgres_subnet_group}"
@murarisumit
murarisumit / getDNSEntryRoute53.py
Last active May 3, 2025 02:51
Get DNS Entry route53 #boto #aws
import boto
r53conn = boto.connect_route53(aws_access_key_id="xxxxxxxxxxxxxx",aws_secret_access_key="yyyyyyyyyy")
recordSets = r53conn.get_zone("yourdomain.in")
#Sorry for the hacky way.....!
for recordset in recordSets.get_records():
print recordset.name + " : " + recordset.to_print()