Skip to content

Instantly share code, notes, and snippets.

sudo apt-get install python3-pip
sudo pip3 install awscli
function install_kops {
if [ -z $(which kops) ]
then
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x kops-linux-amd64
mv kops-linux-amd64 /usr/local/bin/kops
else
resource "aws_route53_zone" "newtech-academy" {
name = "newtech.academy"
}
resource "aws_route53_record" "server1-record" {
zone_id = "${aws_route53_zone.newtech-academy.zone_id}"
name = "server1.newtech.academy"
type = "A"
ttl = "300"
records = ["104.236.247.8"]
}
variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
variable "AWS_REGION" {
default = "eu-west-1"
}
variable "AMIS" {
type = "map"
default = {
resource "aws_instance" "example" {
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "t2.micro"
# the VPC subnet
subnet_id = "${aws_subnet.main-public-1.id}"
# the security group
vpc_security_group_ids = ["${aws_security_group.allow-ssh.id}"]
resource "aws_key_pair" "mykeypair" {
key_name = "mykeypair"
public_key = "${file("${var.PATH_TO_PUBLIC_KEY}")}"
}
provider "aws" {
region = "${var.AWS_REGION}"
access_key = "${var.AWS_ACCESS_KEY}"
secret_key = "${var.AWS_SECRET_KEY}"
}
data "aws_ip_ranges" "european_ec2" {
regions = [
"eu-west-1",
"eu-central-1"
]
services = [
"ec2"
]
}
# nat gw
resource "aws_eip" "nat" {
vpc = true
}
resource "aws_nat_gateway" "nat-gw" {
allocation_id = "${aws_eip.nat.id}"
subnet_id = "${aws_subnet.main-public-1.id}"
depends_on = ["aws_internet_gateway.main-gw"]
}
@himlohiya
himlohiya / vpc.tf
Last active November 30, 2018 14:52
# Internet VPC
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
enable_dns_support = "true"
enable_dns_hostnames = "true"
enable_classiclink = "false"
tags {
Name = "main"
}
from textblob import TextBlob
# compute sentiment scores (polarity) and labels
sentiment_scores_tb = [round(TextBlob(article).sentiment.polarity, 3) for article in news_df['clean_text']]
sentiment_category_tb = ['positive' if score > 0
else 'negative' if score < 0
else 'neutral'
for score in sentiment_scores_tb]