Skip to content

Commit

Permalink
access key
Browse files Browse the repository at this point in the history
  • Loading branch information
ruokun-niu committed Jan 17, 2025
1 parent 00f4ccf commit 7c2e55e
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ pub fn apply_identity(spec: &mut KubernetesSpec, identity: &ServiceIdentity) {
"eks.amazonaws.com/role-arn".to_string(),
arn.to_string(),
);
}
ServiceIdentity::AwsIamAccessKey {
access_key_id,
secret_access_key,
} => {
env_vars.insert("AWS_ACCESS_KEY_ID".to_string(), access_key_id.clone());
env_vars.insert("AWS_SECRET_ACCESS_KEY".to_string(), secret_access_key.clone());

id_type = "AwsIamAccessKey";
}
}

Expand Down
14 changes: 14 additions & 0 deletions control-planes/mgmt_api/src/api/v1/mappings/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ impl From<ServiceIdentityDto> for ServiceIdentity {
ServiceIdentityDto::AwsIamRole { role_arn } => ServiceIdentity::AwsIamRole {
role_arn: role_arn.into(),
},
ServiceIdentityDto::AwsIamAccessKey {
access_key_id,
secret_access_key,
} => ServiceIdentity::AwsIamAccessKey {
access_key_id: access_key_id.into(),
secret_access_key: secret_access_key.into(),
}
}
}
}
Expand Down Expand Up @@ -128,6 +135,13 @@ impl From<ServiceIdentity> for ServiceIdentityDto {
ServiceIdentity::AwsIamRole { role_arn } => ServiceIdentityDto::AwsIamRole {
role_arn: role_arn.into(),
},
ServiceIdentity::AwsIamAccessKey {
access_key_id,
secret_access_key,
} => ServiceIdentityDto::AwsIamAccessKey {
access_key_id: access_key_id.into(),
secret_access_key: secret_access_key.into(),
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions control-planes/mgmt_api/src/api/v1/models/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ pub enum ServiceIdentityDto {
#[serde(rename = "roleArn")]
role_arn: ConfigValueDto,
},
AwsIamAccessKey {
#[serde(rename = "accessKeyId")]
access_key_id: ConfigValueDto,
#[serde(rename = "secretAccessKey")]
secret_access_key: ConfigValueDto,
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
7 changes: 7 additions & 0 deletions control-planes/mgmt_api/src/domain/mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ impl From<ServiceIdentity> for resource_provider_api::models::ServiceIdentity {
role_arn: role_arn.into(),
}
}
ServiceIdentity::AwsIamAccessKey {
access_key_id,
secret_access_key,
} => resource_provider_api::models::ServiceIdentity::AwsIamAccessKey {
access_key_id: access_key_id.into(),
secret_access_key: secret_access_key.into(),
},
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions control-planes/mgmt_api/src/domain/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ pub enum ServiceIdentity {
#[serde(rename = "roleArn")]
role_arn: ConfigValue,
},
AwsIamAccessKey {
#[serde(rename = "accessKeyId")]
access_key_id: ConfigValue,
#[serde(rename = "secretAccessKey")]
secret_access_key: ConfigValue,
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
6 changes: 6 additions & 0 deletions control-planes/resource_provider_api/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ pub enum ServiceIdentity {
#[serde(rename = "roleArn")]
role_arn: ConfigValue,
},
AwsIamAccessKey {
#[serde(rename = "accessKeyId")]
access_key_id: ConfigValue,
#[serde(rename = "secretAccessKey")]
secret_access_key: ConfigValue,
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
14 changes: 13 additions & 1 deletion reactions/aws/eventbridge-reaction/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@
services.AddSingleton<IChangeFormatter, ChangeFormatter>();
services.AddSingleton<AmazonEventBridgeClient>(sp =>
{
return new AmazonEventBridgeClient();
var configuration = sp.GetRequiredService<IConfiguration>();
switch (configuration.GetIdentityType())
{
case IdentityType.AwsIamRole:
return new AmazonEventBridgeClient();
case IdentityType.AwsIamAccessKey:
var accessKey = configuration.GetAwsIamAccessKeyId();
var secretKey = configuration.GetAwsIamSecretKey();
return new AmazonEventBridgeClient(accessKey, secretKey);
default:
Reaction<object>.TerminateWithError("Invalid Identity Type. Valid values are AwsIamRole and AwsIamAccessKey");
throw new Exception("Invalid Identity Type. Valid values are AwsIamRole and AwsIamAccessKey");
}
});
})
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="AWSSDK.EventBridge" Version="3.7.402.17" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.401.29" />
<PackageReference Include="Drasi.Reaction.SDK" Version="0.1.7-alpha" />
<PackageReference Include="Drasi.Reaction.SDK" Version="0.1.8-alpha" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public static IdentityType GetIdentityType(this IConfiguration config)
"MicrosoftEntraWorkloadID" => IdentityType.MicrosoftEntraWorkloadID,
"ConnectionString" => IdentityType.ConnectionString,
"AccessKey" => IdentityType.AccessKey,
"AwsIamRole" => IdentityType.AwsIamRole,
"AwsIamAccessKey" => IdentityType.AwsIamAccessKey,
_ => IdentityType.None,
};
}
Expand All @@ -25,13 +27,25 @@ public static IdentityType GetIdentityType(this IConfiguration config)
{
return config.GetValue<string>("ACCESS_KEY");
}

public static string? GetAwsIamAccessKeyId(this IConfiguration config)
{
return config.GetValue<string>("AWS_ACCESS_KEY_ID");
}

public static string? GetAwsIamSecretKey(this IConfiguration config)
{
return config.GetValue<string>("AWS_SECRET_ACCESS_KEY");
}
}

public enum IdentityType
{
None,
MicrosoftEntraWorkloadID,
ConnectionString,
AccessKey
AccessKey,
AwsIamRole,
AwsIamAccessKey,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/drasi-project/drasi-platform.git</RepositoryUrl>
<Version>0.1.5</Version>
<Version>0.1.8</Version>
<PackageIcon>drasi.png</PackageIcon>
<PackageVersion>0.1.5-alpha</PackageVersion>
<PackageVersion>0.1.8-alpha</PackageVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down

0 comments on commit 7c2e55e

Please sign in to comment.