Skip to content

Commit 7ac0aeb

Browse files
authored
Merge pull request #149 from tebanieo/master
Bugfix: mysql imdb files, source db not binding ip and docker
2 parents 93aeef4 + c58022e commit 7ac0aeb

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

design-patterns/cloudformation/vscode.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ Parameters:
1111
Type: String
1212
Description: Location of LADV code ZIP
1313
Default: https://amazon-dynamodb-labs.com/assets/workshop.zip
14-
LBEDZIP:
15-
Type: String
16-
Description: Location of LBED code ZIP
17-
Default: https://amazon-dynamodb-labs.com/assets/OpenSearchPipeline.zip
1814
DBLatestAmiId:
1915
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
2016
Default: '/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64'
@@ -1640,8 +1636,6 @@ Resources:
16401636
- mkdir -p /tmp
16411637
- !Sub curl -o /tmp/workshop.zip "${WorkshopZIP}"
16421638
- !Sub unzip -o /tmp/workshop.zip -d ${VSCodeHomeFolder}/LADV
1643-
- !Sub curl -o /tmp/lbed.zip "${LBEDZIP}"
1644-
- !Sub unzip -jo /tmp/lbed.zip unzip -jo /tmp/lbed.zip "OpenSearchPipeline/*" -d ${VSCodeHomeFolder}/LBED
16451639
- rm /tmp/workshop.zip
16461640
- !Sub echo "${DDBReplicationRole.Arn}" > ${VSCodeHomeFolder}/ddb-replication-role-arn.txt
16471641
- !Sub chown -R ${VSCodeUser}:${VSCodeUser} ${VSCodeHomeFolder}
@@ -1783,10 +1777,10 @@ Resources:
17831777
UPDATE mysql.user SET host='%' WHERE user='${DbMasterUsername}';
17841778
FLUSH PRIVILEGES;
17851779
"
1786-
- echo "Configuring MySQL settings for remote access and performance logging..."
1780+
- echo "Creating MySQL configuration file for remote access..."
17871781
- !Sub |
1788-
cat >> /etc/mysql/mysql.conf.d/mysqld.cnf <<EOF
1789-
1782+
sudo tee /etc/my.cnf.d/mysql-server-custom.cnf <<EOF
1783+
[mysqld]
17901784
# Remote access configuration
17911785
bind-address = 0.0.0.0
17921786
@@ -1802,6 +1796,9 @@ Resources:
18021796
18031797
# Performance schema for detailed monitoring
18041798
performance_schema = ON
1799+
1800+
# Security settings for remote access
1801+
skip-name-resolve
18051802
EOF
18061803
- echo "Creating MySQL log directory and setting permissions..."
18071804
- sudo mkdir -p /var/log/mysql
@@ -1979,6 +1976,8 @@ Resources:
19791976
- "docker --version"
19801977
- "docker-compose --version"
19811978
- echo "Docker installation completed successfully."
1979+
- echo "Restarting code-server to pick up docker group membership..."
1980+
- !Sub "systemctl restart code-server@${VSCodeUser}"
19821981
- name: CloneWorkshop
19831982
action: aws:runShellScript
19841983
inputs:
@@ -2216,13 +2215,15 @@ Resources:
22162215
PRIMARY KEY (nconst)
22172216
);" || echo "Warning: Failed to create name_basics table"
22182217
- echo "Loading IMDB data into tables..."
2218+
- echo "Creating secure file directory for MySQL..."
2219+
- sudo mkdir -p /var/lib/mysql-files
2220+
- sudo chown mysql:mysql /var/lib/mysql-files
2221+
- sudo chmod 755 /var/lib/mysql-files
22192222
- !Sub |
2220-
# Copy files to MySQL secure file directory
2221-
sudo cp /tmp/imdb-data/*.tsv /var/lib/mysql-files/ 2>/dev/null || {
2222-
echo "Warning: Could not copy TSV files to MySQL secure directory"
2223-
# Try alternative approach - load from tmp directory with LOCAL INFILE
2224-
mysql -u ${DbMasterUsername} -p"${DbMasterPassword}" -e "SET GLOBAL local_infile=1;"
2225-
}
2223+
# Copy files to MySQL secure file directory with proper permissions
2224+
sudo cp /tmp/imdb-data/*.tsv /var/lib/mysql-files/
2225+
sudo chown mysql:mysql /var/lib/mysql-files/*.tsv
2226+
sudo chmod 644 /var/lib/mysql-files/*.tsv
22262227
- !Sub |
22272228
# Function to load data with error handling
22282229
load_imdb_data() {
@@ -3029,4 +3030,4 @@ Outputs:
30293030
Value: !Sub "Username: ${DbMasterUsername}, Password: ${DbMasterPassword}"
30303031
MySQLInstancePrivateIP:
30313032
Description: Private IP Address of MySQL instance (use this for JDBC connections from Glue)
3032-
Value: !GetAtt DbInstance.PrivateIp
3033+
Value: !GetAtt DbInstance.PrivateIp

0 commit comments

Comments
 (0)