Skip to content

Instantly share code, notes, and snippets.

@kencoba
Created September 22, 2024 07:59
Show Gist options
  • Select an option

  • Save kencoba/83c005ba9a11890eb7ff9c54aa907a3f to your computer and use it in GitHub Desktop.

Select an option

Save kencoba/83c005ba9a11890eb7ff9c54aa907a3f to your computer and use it in GitHub Desktop.

Revisions

  1. kencoba created this gist Sep 22, 2024.
    38 changes: 38 additions & 0 deletions 03_SecurityGroup.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    AWSTemplateFormatVersion: '2010-09-09'
    Description: CloudFormation template to create a Security Group allowing inbound traffic on port 3306 for MariaDB.

    Parameters:
    VpcId:
    Type: AWS::EC2::VPC::Id
    Description: VPC ID to create the security group in.
    Prefix:
    Type: String
    Default: MyApp
    Description: Prefix for all resource names
    Resources:
    MyMariaDBSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
    GroupDescription: Security group for MariaDB allowing inbound traffic on port 3306
    VpcId: !Ref VpcId
    SecurityGroupIngress:
    - IpProtocol: tcp
    FromPort: 3306
    ToPort: 3306
    CidrIp: 0.0.0.0/0 # Allows access from any IP (adjust as needed)
    SecurityGroupEgress:
    - IpProtocol: -1 # Allow all outbound traffic
    FromPort: -1
    ToPort: -1
    CidrIp: 0.0.0.0/0
    Tags:
    - Key: Name
    Value: !Sub "${Prefix}-sg"


    Outputs:
    SecurityGroupId:
    Description: The Security Group ID for MariaDB
    Value: !Ref MyMariaDBSecurityGroup
    Export:
    Name: MariaDBSecurityGroupId