Skip to content

Instantly share code, notes, and snippets.

@AymenSegni
Created April 12, 2020 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AymenSegni/bd7abeca3efcb89b2e319401ba95f380 to your computer and use it in GitHub Desktop.
Save AymenSegni/bd7abeca3efcb89b2e319401ba95f380 to your computer and use it in GitHub Desktop.
// main.tf
resource "aws_s3_bucket" "kops_state" {
bucket = "${var.environment}-kops-s3"
acl = "private"
versioning {
enabled = true
}
tags = {
Environment = var.environment
Application = "kops"
Description = "S3 Bucket for KOPS state"
}
}
resource "aws_security_group" "k8s_api_http" {
name = "${var.environment}-k8s-api-http"
vpc_id = var.vpc_id
tags = {
environment = var.environment
terraform = true
}
ingress {
protocol = "tcp"
from_port = 80
to_port = 80
cidr_blocks = var.ingress_ips
}
ingress {
protocol = "tcp"
from_port = 443
to_port = 443
cidr_blocks = var.ingress_ips
}
}
// variables.tf
variable "ingress_ips" {
type = list
description = "List of Ingress IPs"
}
variable "environment" {
type = string
default = "krypton"
description = "Name prefix"
}
variable "vpc_id" {
type = string
description = "the shared vpc id"
}
// outputs.tf
output "k8s_api_http_security_group_id" {
value = aws_security_group.k8s_api_http.id
}
output "kops_s3_bucket_name" {
value = aws_s3_bucket.kops_state.bucket
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment