Skip to content

Commit

Permalink
Merge pull request #15 from AWS-Cloud-School-6/14-fix-roll-back
Browse files Browse the repository at this point in the history
#14 Fix: Roll Back
  • Loading branch information
nareunhang authored Nov 13, 2024
2 parents d17d158 + 781958f commit f5fb47b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public ListResult<MemberResponseDto> getAllMembers() {
}

@PostMapping("/update-credentials")
public CommonResult updateCredentials(@RequestBody CompanyDto companyDto) {
System.out.println(companyDto.getAccessKey());
System.out.println(companyDto.getSecretKey());
memberService.addOrUpdateKeys(companyDto.getUserId(),companyDto.getCompany(),companyDto.getAccessKey(), companyDto.getSecretKey());
public CommonResult updateCredentials(@RequestBody MemberCredentialDTO memberCredentialDTO) {
System.out.println(memberCredentialDTO.getAccessKey());
System.out.println(memberCredentialDTO.getSecretKey());
memberService.addOrUpdateKeys(memberCredentialDTO.getEmail(),memberCredentialDTO.getAccessKey(), memberCredentialDTO.getSecretKey());
return responseService.getSuccessResult();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public Member registerMember(MemberRequestDto memberRequestDto) {
if (memberRepository.findByEmail(memberRequestDto.getEmail()) != null) {
throw new RuntimeException("Email already exists");
}
s3Service.createUserDirectory(memberRequestDto.getEmail());
Member regiMember=new Member(memberRequestDto.getName(), memberRequestDto.getPassword(), memberRequestDto.getEmail());

return memberRepository.save(regiMember);
}

Expand Down Expand Up @@ -57,13 +59,12 @@ public List<Member> getAllMembers() {
}


public Member addOrUpdateKeys(String email, String company,String access_key,String secret_key) {
public Member addOrUpdateKeys(String email,String access_key,String secret_key) {

Member member = getMemberByEmail(email);
member.setAccess_key(access_key);
member.setSecret_key(secret_key);
s3Service.createUserDirectory(company);
s3Service.createTfvarsFile(company,access_key,secret_key);
s3Service.createTfvarsFile(email,access_key,secret_key);
return memberRepository.save(member);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class S3Service {
private final AmazonS3 s3Client;
private final String bucketName = "aiwa-terraform";

public void createUserDirectory(String company) {
String userPrefix = "users/" + company + "/";
public void createUserDirectory(String userId) {
String userPrefix = "users/" + userId + "/";
// 초기 main.tf 및 terraform.tfstate 파일을 업로드합니다
uploadInitialFiles(userPrefix);
}
Expand Down Expand Up @@ -64,8 +64,8 @@ public void deleteUserDirectory(String userId) {
}


public void createTfvarsFile(String company, String accessKey, String secretKey) {
String userPrefix = "users/" + company + "/";
public void createTfvarsFile(String userId, String accessKey, String secretKey) {
String userPrefix = "users/" + userId + "/";
String tfvarsContent = String.format("""
aws_access_key = "%s"
aws_secret_key = "%s"
Expand Down

0 comments on commit f5fb47b

Please sign in to comment.