Skip to content

Commit

Permalink
iac
Browse files Browse the repository at this point in the history
  • Loading branch information
ideaMarcos committed Jan 28, 2025
1 parent 9b3cabd commit 678e65d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,elixir,phoenix,visualstudiocode,database
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,elixir,phoenix,visualstudiocode,database
# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,elixir,phoenix,database,visualstudiocode,terraform
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,elixir,phoenix,database,visualstudiocode,terraform

### Database ###
*.accdb
Expand Down Expand Up @@ -97,6 +97,44 @@ Temporary Items
/installer/doc
/installer/deps

### Terraform ###
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

.terraform.lock.hcl

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
Expand All @@ -116,4 +154,4 @@ Temporary Items
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/linux,macos,elixir,phoenix,visualstudiocode,database
# End of https://www.toptal.com/developers/gitignore/api/linux,macos,elixir,phoenix,database,visualstudiocode,terraform
45 changes: 45 additions & 0 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
terraform {
required_version = ">= 0.12"
}

provider "aws" {
region = "us-east-1"
}

data "aws_region" "current-region" {}

locals {
docker_image = "ideamarcos-boneyard"
registry_id = "000000000000"
}

resource "aws_ecr_repository" "ecr_repo" {
name = "localstack-ecr-repo"
image_tag_mutability = "MUTABLE" # or "IMMUTABLE" based on your requirement
image_scanning_configuration {
scan_on_push = true
}
}

resource "null_resource" "builder" {
provisioner "local-exec" {
interpreter = ["/bin/bash", "-c"]
working_dir = path.module
command = "docker build -t ${local.docker_image} ../"
}
provisioner "local-exec" {
interpreter = ["/bin/bash", "-c"]
working_dir = path.module
command = "docker tag ${local.docker_image} ${local.registry_id}.dkr.ecr.${data.aws_region.current-region.name}.localhost.localstack.cloud:4566/${aws_ecr_repository.ecr_repo.name}"
}
provisioner "local-exec" {
interpreter = ["/bin/bash", "-c"]
working_dir = path.module
command = "docker push ${local.registry_id}.dkr.ecr.${data.aws_region.current-region.name}.localhost.localstack.cloud:4566/${aws_ecr_repository.ecr_repo.name}"
}
}

output "command_output" {
value = null_resource.builder.id
description = "Output from builder"
}

0 comments on commit 678e65d

Please sign in to comment.