Skip to content

Instantly share code, notes, and snippets.

@Ina-Exter
Ina-Exter / terraform_plan.txt
Created February 19, 2020 12:56
terraform output for article on terraform
xg-debian@debian:~/terraform-example$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
@Ina-Exter
Ina-Exter / terraform_init.txt
Created February 19, 2020 12:51
terraform init for article on terraform
xg@debian:~/terraform$ terraform init
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.49.0...
The following providers do not have any version constraints in configuration,
so the latest version was installed.
@Ina-Exter
Ina-Exter / s3_gcp.tf
Created February 5, 2020 13:56
s3_gcp.tf for article on terraform
resource "google_storage_bucket" "bucket" {
name = "my-bucket-on-gcp"
location = "EU"
website {
main_page_suffix = "index.html"
not_found_page = "404.html"
}
}
@Ina-Exter
Ina-Exter / s3_aws.tf
Created February 5, 2020 13:56
s3_aws.tf for article on terraform
resource "aws_s3_bucket" "bucket" {
bucket = "my-bucket-on-aws"
acl = "public-read"
policy = "${file("bucketpolicy.json")}"
website {
index_document = "index.html"
error_document = "error.html"
}
}
@Ina-Exter
Ina-Exter / output.tf
Created February 5, 2020 13:55
output.tf for article on terraform
output "bastion-ip" {
value = aws_instance.my-ec2-bastion.public_ip
}
@Ina-Exter
Ina-Exter / tag.tf
Created February 5, 2020 13:51
tags example for article on terraform
tags = {
Name = "my-resource-name-${var.profile}"
}
@Ina-Exter
Ina-Exter / variables.tf
Created February 5, 2020 13:50
variables.tf for article on terraform
#Nom de profil AWS
variable "profile" {
#Valeur par défaut
default = "default"
}
variable "ip" {
#Sans valeur par défaut
}
@Ina-Exter
Ina-Exter / s3.tf
Last active February 14, 2020 10:48
s3.tf for article on terraform
resource "aws_s3_bucket" "my-bucket-example" {
bucket = "my-bucket-example-23413426676567"
acl = "public-read"
}
resource "aws_s3_bucket_object" "picture-of-cat" {
bucket = aws_s3_bucket.my-bucket-example.id
key = "cat.jpg"
acl = "public-read"
@Ina-Exter
Ina-Exter / provider.tf
Created February 5, 2020 13:49
provider.tf for article on terraform
provider "aws" {
profile = "altaccount"
region = "eu-west-1"
}
@Ina-Exter
Ina-Exter / ec2.tf
Last active February 5, 2020 14:06
ec2.tf for article on terraform
#Créer une paire de clés dans terraform requiert d'utiliser sa clé publique comme matériel. Il est
#recommandé d'utiliser `$ ssh-keygen -t rsa` pour en créer une et la remplacer ici.
resource "aws_key_pair" "my-key" {
key_name = "my-key"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUNl0PHsE9is7/PB0OilYBt3gUuQOlS4DM1jtN+WVP8DsgufiUWdbIFtKX0Q4P/tvkez5r7XVHOSDPliswatHisDK5aNCjW20VGI1Tf0lljoLVoIHSZgHPgj7L+3v40vLCkrMojpc9c6S5KH2fRh8qKDhMe9Qnw197WSFwItRNq4PsKHZvQQuZIkoolzfp4OwM7rkcazLfD3GW2JWo95Ut/Pw+L0tjx478+7KIsHoz4uyT1N7Lc90rb6EY/d3J1grvgWm82/mAZnFmPVEurnNsMIOAmh+Bv3yhYJQdNFX7mHln6/JFo3ei2tFVna3Yv0sOpnn2+2wlatUMwD8t7+TP example@example"
}
#Permet de déclarer un group de sécurité pour EC2, sans quoi il ne sera pas possible d'y accéder
resource "aws_security_group" "my-security-group" {
#Il est nécessaire de nommer le security group, mais optionnel de lui donner une description