Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ec2): add support for environment files and variables in systemd #29629

Merged
merged 11 commits into from
May 1, 2024

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"IntegInitVpcPublicSubnet1Subnet41A6F6D4": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"AvailabilityZone": {
"Fn::Select": [
0,
Expand All @@ -44,21 +41,24 @@
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PublicSubnet1"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPublicSubnet1RouteTable837CD5FB": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"Tags": [
{
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PublicSubnet1"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPublicSubnet1RouteTableAssociation00D33741": {
Expand All @@ -75,12 +75,12 @@
"IntegInitVpcPublicSubnet1DefaultRoute5BB90E8C": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "IntegInitVpcIGWF019AC85"
},
"RouteTableId": {
"Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB"
}
},
"DependsOn": [
Expand All @@ -102,15 +102,15 @@
"IntegInitVpcPublicSubnet1NATGateway46F32F7F": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"SubnetId": {
"Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4"
},
"AllocationId": {
"Fn::GetAtt": [
"IntegInitVpcPublicSubnet1EIP46FCC3D6",
"AllocationId"
]
},
"SubnetId": {
"Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4"
},
"Tags": [
{
"Key": "Name",
Expand All @@ -126,9 +126,6 @@
"IntegInitVpcPublicSubnet2Subnet9A384F16": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"AvailabilityZone": {
"Fn::Select": [
1,
Expand All @@ -152,21 +149,24 @@
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PublicSubnet2"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPublicSubnet2RouteTableF7E8F920": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"Tags": [
{
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PublicSubnet2"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPublicSubnet2RouteTableAssociationB816F9F3": {
Expand All @@ -183,12 +183,12 @@
"IntegInitVpcPublicSubnet2DefaultRoute2393995F": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "IntegInitVpcIGWF019AC85"
},
"RouteTableId": {
"Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920"
}
},
"DependsOn": [
Expand All @@ -210,15 +210,15 @@
"IntegInitVpcPublicSubnet2NATGateway9CCB4A9C": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"SubnetId": {
"Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16"
},
"AllocationId": {
"Fn::GetAtt": [
"IntegInitVpcPublicSubnet2EIP553B40DC",
"AllocationId"
]
},
"SubnetId": {
"Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16"
},
"Tags": [
{
"Key": "Name",
Expand All @@ -234,9 +234,6 @@
"IntegInitVpcPrivateSubnet1Subnet259B51C1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"AvailabilityZone": {
"Fn::Select": [
0,
Expand All @@ -260,21 +257,24 @@
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PrivateSubnet1"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPrivateSubnet1RouteTableCB37994B": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"Tags": [
{
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PrivateSubnet1"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPrivateSubnet1RouteTableAssociation067DEF9D": {
Expand All @@ -291,21 +291,18 @@
"IntegInitVpcPrivateSubnet1DefaultRoute654ACECF": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "IntegInitVpcPublicSubnet1NATGateway46F32F7F"
},
"RouteTableId": {
"Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B"
}
}
},
"IntegInitVpcPrivateSubnet2Subnet1643B059": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"AvailabilityZone": {
"Fn::Select": [
1,
Expand All @@ -329,21 +326,24 @@
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PrivateSubnet2"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPrivateSubnet2RouteTable030EC93B": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"Tags": [
{
"Key": "Name",
"Value": "integ-init/IntegInitVpc/PrivateSubnet2"
}
]
],
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
"IntegInitVpcPrivateSubnet2RouteTableAssociation6B52BD72": {
Expand All @@ -360,12 +360,12 @@
"IntegInitVpcPrivateSubnet2DefaultRoute6A10B6EA": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "IntegInitVpcPublicSubnet2NATGateway9CCB4A9C"
},
"RouteTableId": {
"Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B"
}
}
},
Expand All @@ -383,11 +383,11 @@
"IntegInitVpcVPCGW85EDC292": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
},
"InternetGatewayId": {
"Ref": "IntegInitVpcIGWF019AC85"
},
"VpcId": {
"Ref": "IntegInitVpc0D4FCCB3"
}
}
},
Expand Down Expand Up @@ -513,7 +513,7 @@
]
}
},
"Instance255F35265a0c5f577d761edb0": {
"Instance255F3526574cbd507dfce8b71": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": {
Expand Down Expand Up @@ -553,23 +553,23 @@
"Fn::Join": [
"",
[
"#!/bin/bash\n# fingerprint: 89cb2e09a1c3d4c8\n(\n set +e\n /opt/aws/bin/cfn-init -v --region ",
"#!/bin/bash\n# fingerprint: 4f2827c68bde31b4\n(\n set +e\n /opt/aws/bin/cfn-init -v --region ",
{
"Ref": "AWS::Region"
},
" --stack ",
{
"Ref": "AWS::StackName"
},
" --resource Instance255F35265a0c5f577d761edb0 -c default\n /opt/aws/bin/cfn-signal -e $? --region ",
" --resource Instance255F3526574cbd507dfce8b71 -c default\n /opt/aws/bin/cfn-signal -e $? --region ",
{
"Ref": "AWS::Region"
},
" --stack ",
{
"Ref": "AWS::StackName"
},
" --resource Instance255F35265a0c5f577d761edb0\n cat /var/log/cfn-init.log >&2\n)"
" --resource Instance255F3526574cbd507dfce8b71\n cat /var/log/cfn-init.log >&2\n)"
]
]
}
Expand Down Expand Up @@ -641,6 +641,24 @@
"group": "root"
}
}
},
"service": {
"files": {
"/myvars.env": {
"content": "OTHER_VAR=\"im from the file :3\"",
"encoding": "plain",
"mode": "000644",
"owner": "root",
"group": "root"
},
"/etc/systemd/system/myapp.service": {
"content": "[Unit]\nAfter=network.target\n[Service]\nExecStart=/bin/bash -c \"echo HELLO_WORLD=${MY_VAR} | FROM_FILE=${OTHER_VAR}\"\nRestart=always\nEnvironmentFile=/myvars.env\nEnvironment=\"MY_VAR=its me :)\"\n[Install]\nWantedBy=multi-user.target",
"encoding": "plain",
"mode": "000644",
"owner": "root",
"group": "root"
}
}
}
},
"AWS::CloudFormation::Authentication": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading