This file contains hidden or 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
## get_instance_identity_document() : | |
## Code generated by chatgpt with the following request: | |
## I have an python script running in an AWS EC2 instance. | |
## I would like a function to retrieve the Instance Identity document from the instance metadata. | |
## (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html) | |
## The function should check whether the instance is using v1 (direct request) or v2 (token) of the instance metadata service and act accordingly | |
## First ChatGPT output was wrong: Didn't use the token for imdsv2 and used a different (wrong) URL for the imdsv1 query | |
import requests |
This file contains hidden or 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
resource "google_compute_firewall" "ssh" { | |
name = "foo-ssh" | |
allow { | |
ports = ["22"] | |
protocol = "tcp" | |
} | |
direction = "INGRESS" | |
network = google_compute_network.some_vpc.id | |
priority = 1000 | |
source_ranges = ["0.0.0.0/0"] |
This file contains hidden or 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
## Assume aws_instance resource called "flask1" | |
output "public_ip" { | |
description = "Public IP of instance" | |
value = aws_instance.flask1.public_ip | |
} | |
output "key_name" { | |
description = "SSH Key Name" | |
value = aws_instance.flask1.key_name |
This file contains hidden or 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
data "aws_ami" "amazon_linux2_kernel_5" { | |
most_recent = true | |
owners = ["amazon"] | |
filter { | |
name = "name" | |
values = ["amzn2-ami-kernel-5.10-hvm-2.0*x86_64-gp2"] | |
} | |
filter { |
This file contains hidden or 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
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = ">= 4.6" # v3.38.0 minimal version to use default tags | |
} | |
} | |
} | |
provider "aws" { |
This file contains hidden or 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
# Source: https://github.com/terraform-providers/terraform-provider-aws/blob/master/examples/eks-getting-started/workstation-external-ip.tf | |
# | |
# Workstation External IP | |
# | |
# This configuration is not required and is | |
# only provided as an example to easily fetch | |
# the external IP of your local workstation to | |
# configure inbound EC2 Security Group access | |
# to the Kubernetes cluster. | |
# |
This file contains hidden or 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
--- | |
Parameters: | |
ipBlockParam: | |
Description: IP cidr block for VPC | |
Default: "172.16.0.0/16" | |
Type: String | |
MinLength: '9' | |
MaxLength: '18' | |
AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})' | |
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x. |
This file contains hidden or 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 numpy as np | |
positions = ['GK', 'M', 'A', 'D'] | |
heights = [191, 184, 185, 180] | |
# Convert positions and heights to numpy arrays: np_positions, np_heights | |
np_heights = np.array(heights) | |
np_positions = np.array(positions) | |
# Heights of the goalkeepers: gk_heights |
This file contains hidden or 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 numpy as np; | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
np.random.seed(42) | |
# df from np.ndarray | |
df = pd.DataFrame(data = np.random.random(size=(4,4))*100, columns = ['A','B','C','D']) | |
df.plot(kind='box') | |
plt.show() |
This file contains hidden or 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
# Typical / useful include | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import pandas_profiling as pp | |
import plotly.express as px | |
import plotly.graph_objs as go | |
from plotly.offline import iplot | |
import plotly.express as px |
NewerOlder