Skip to content

Commit f22ad2a

Browse files
committed
Initial commit
1 parent 1b725e1 commit f22ad2a

File tree

5 files changed

+245
-1
lines changed

5 files changed

+245
-1
lines changed

.devcontainer/devcontainer.json

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
// "name" specifies the name of the development container, which helps in identifying it in a list of containers.
3+
"name": "Ubuntu",
4+
5+
// "build" section is used to define how the development container is built. It can reference a Dockerfile or a Docker Compose file.
6+
"build": {
7+
"dockerfile": "dockerfile" // Specifies the Dockerfile to use for building the container.
8+
},
9+
10+
// "features" section allows adding and configuring predefined features or tools in the development container.
11+
"features": {
12+
// Adds and configures the Azure CLI with Bicep and Python installation options.
13+
"ghcr.io/devcontainers/features/azure-cli:latest": {
14+
"installBicep": true, // Enables Bicep installation.
15+
"installUsingPython": true, // Installs using Python.
16+
"version": "latest" // Specifies the version of the Azure CLI to install.
17+
},
18+
// Adds PowerShell to the container.
19+
"ghcr.io/devcontainers/features/powershell:latest": {
20+
"version": "latest" // Specifies the version of PowerShell to install.
21+
},
22+
// Adds Azure Bicep support.
23+
"ghcr.io/rchaganti/vsc-devcontainer-features/azurebicep:latest": {},
24+
// Adds Azure Developer CLI (azd) support.
25+
"ghcr.io/azure/azure-dev/azd:latest": {},
26+
// Adds and configures Terraform with specific version, TFLint, and Terragrunt.
27+
"ghcr.io/devcontainers/features/terraform:1": {
28+
"version": "latest", // Specifies the version of Terraform to install.
29+
"tflint": "latest", // Specifies the version of TFLint to install.
30+
"terragrunt": "latest" // Specifies the version of Terragrunt to install.
31+
}
32+
},
33+
34+
// "customizations" section allows configuring specific aspects of the development environment, such as VS Code settings and extensions.
35+
"customizations": {
36+
"vscode": {
37+
// Defines VS Code settings to be applied within the dev container.
38+
"settings": {
39+
"editor.formatOnSaveMode": "file", // Configures format on save to be applied to the entire file.
40+
"bicep.experimental.deployPane": "true" // Enables the experimental deploy pane for Bicep.
41+
},
42+
// Lists VS Code extensions to be installed in the dev container environment.
43+
"extensions": [
44+
"ms-azuretools.vscode-azurecontainerapps",
45+
"ms-azuretools.vscode-azureresourcegroups",
46+
"ms-azuretools.vscode-bicep",
47+
"editorconfig.editorconfig",
48+
"BenjaminBenais.copilot-theme",
49+
"GitHub.copilot",
50+
"GitHub.copilot-chat",
51+
"ms-vscode.azure-account",
52+
"hashicorp.terraform",
53+
"golang.Go"
54+
]
55+
}
56+
}
57+
58+
// Additional sections can be uncommented and configured as needed for port forwarding, post-creation commands, and other customizations.
59+
}
60+
61+
// Features to add to the dev container. More info: https://containers.dev/features.
62+
// "features": {},
63+
64+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
65+
// "forwardPorts": [],
66+
67+
// Use 'postCreateCommand' to run commands after the container is created.
68+
// "postCreateCommand": "uname -a",
69+
70+
// Configure tool-specific properties.
71+
// "customizations": {},
72+
73+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
74+
// "remoteUser": "root"
75+
}

.devcontainer/dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This line specifies the base image for the Docker container.
2+
# "FROM" is a Docker instruction used to set the base image from which the container is built.
3+
# "mcr.microsoft.com/devcontainers/universal:latest" is the image being used.
4+
# It is a universal image provided by Microsoft, hosted on the Microsoft Container Registry (MCR),
5+
# designed for development containers. The "latest" tag specifies the most recent version of this image.
6+
FROM mcr.microsoft.com/devcontainers/universal:latest

.github/workflows/mega-linter.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
# MegaLinter GitHub Action configuration file
3+
# More info at https://megalinter.io
4+
name: MegaLinter
5+
6+
on:
7+
push:
8+
branches:
9+
- "**"
10+
11+
env: # Comment env block if you do not want to apply fixes
12+
# Apply linter fixes configuration
13+
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
14+
APPLY_FIXES_EVENT: all # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
15+
APPLY_FIXES_MODE: pull_request # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
16+
17+
concurrency:
18+
group: ${{ github.ref }}-${{ github.workflow }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
name: MegaLinter
24+
runs-on: ubuntu-latest
25+
permissions:
26+
# Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR
27+
# Remove the ones you do not need
28+
contents: write
29+
issues: write
30+
pull-requests: write
31+
steps:
32+
# Git Checkout
33+
- name: Checkout Code
34+
uses: actions/checkout@v3
35+
with:
36+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
37+
fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances
38+
39+
# MegaLinter
40+
- name: MegaLinter
41+
id: ml
42+
# You can override MegaLinter flavor used to have faster performances
43+
# More info at https://megalinter.io/flavors/
44+
uses: oxsecurity/megalinter@beta
45+
env:
46+
# All available variables are described in documentation
47+
# https://megalinter.io/configuration/
48+
VALIDATE_ALL_CODEBASE: true
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
51+
APPLY_FIXES: all
52+
DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
53+
54+
# Upload MegaLinter artifacts
55+
- name: Archive production artifacts
56+
if: ${{ success() }} || ${{ failure() }}
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: MegaLinter reports
60+
path: |
61+
megalinter-reports
62+
mega-linter.log
63+
64+
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
65+
- name: Create Pull Request with applied fixes
66+
id: cpr
67+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
68+
uses: peter-evans/create-pull-request@v5
69+
with:
70+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
71+
commit-message: "[MegaLinter] Apply linters automatic fixes"
72+
title: "[MegaLinter] Apply linters automatic fixes"
73+
labels: bot
74+
- name: Create PR output
75+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
76+
run: |
77+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
78+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
79+
80+
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
81+
- name: Prepare commit
82+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
83+
run: sudo chown -Rc $UID .git/
84+
- name: Commit and push applied linter fixes
85+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
86+
uses: stefanzweifel/git-auto-commit-action@v4
87+
with:
88+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
89+
commit_message: "[MegaLinter] Apply linters fixes"
90+
commit_user_name: megalinter-bot
91+
commit_user_email: [email protected]

.gitignore

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Megalinter reports
2+
megalinter-reports/
3+
# Local .terraform directories
4+
**/.terraform/*
5+
6+
# .tfstate files
7+
*.tfstate
8+
*.tfstate.*
9+
10+
# Crash log files
11+
crash.log
12+
crash.*.log
13+
14+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
15+
# password, private keys, and other secrets. These should not be part of version
16+
# control as they are data points which are potentially sensitive and subject
17+
# to change depending on the environment.
18+
*.tfvars
19+
*.tfvars.json
20+
21+
# Ignore override files as they are usually used to override resources locally and so
22+
# are not checked in
23+
override.tf
24+
override.tf.json
25+
*_override.tf
26+
*_override.tf.json
27+
28+
# Include override files you do wish to add to version control using negated pattern
29+
# !example_override.tf
30+
31+
# Ignore Terraform lock file
32+
.terraform.lock.hcl
33+
34+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
35+
# example: *tfplan*
36+
37+
# Ignore CLI configuration files
38+
.terraformrc
39+
terraform.rc
40+
avmmakefile
41+
README-generated.md
42+
avm.tflint.hcl
43+
avm.tflint_example.hcl
44+
avm.tflint_module.hcl
45+
avm.tflint.merged.hcl
46+
avm.tflint_example.merged.hcl
47+
avm.tflint_module.merged.hcl
48+
*tfplan*
49+
*.md.tmp
50+
# MacOS
51+
.DS_Store

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# Codespace_IaC_Coding
2-
IaC Coding Codespace
2+
3+
This repository contains the code for IaC (Infrastructure as Code) coding in Codespace.
4+
5+
## Development Environment
6+
7+
This project uses a Docker container as a development environment, which includes tools like Azure CLI, PowerShell, Azure Bicep, Azure Developer CLI (azd), Terraform, TFLint, and Terragrunt.
8+
9+
- **Azure CLI**: Used for managing Azure resources.
10+
- **PowerShell**: A cross-platform task automation solution.
11+
- **Azure Bicep**: A declarative language for deploying Azure resources.
12+
- **Azure Developer CLI (azd)**: Streamlines the process of building, deploying, and managing Azure applications.
13+
- **Terraform**: An open-source tool for building, changing, and versioning infrastructure safely and efficiently.
14+
- **TFLint**: A Terraform linter for detecting errors that cannot be detected by `terraform plan`.
15+
- **Terragrunt**: A thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules.
16+
17+
## Code Quality and Linting
18+
19+
This project uses [MegaLinter](https://megalinter.io/latest/) to ensure code quality and adherence to best practices. [MegaLinter](https://megalinter.io/latest/) analyzes the codebase for potential issues, coding standards violations, formatting discrepancies, and more across multiple languages and file formats. It helps maintain a high standard of code quality and consistency across the project.
20+
21+
## Contributing
22+
23+
We welcome contributions to the `Codespace_IaC_Coding` project. Feel free to open a pull-request.

0 commit comments

Comments
 (0)